summaryrefslogtreecommitdiffstats
path: root/src/H5Cimage.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2023-07-28 19:33:16 (GMT)
committerGitHub <noreply@github.com>2023-07-28 19:33:16 (GMT)
commit8ddf2706f7e0cde59fad6624e2863960e62f6544 (patch)
treef090bb9fa368c90f67029f5d860ef39df3e8b038 /src/H5Cimage.c
parentb1ab59d239c74cdbea7d518b1398458c4150655f (diff)
downloadhdf5-8ddf2706f7e0cde59fad6624e2863960e62f6544.zip
hdf5-8ddf2706f7e0cde59fad6624e2863960e62f6544.tar.gz
hdf5-8ddf2706f7e0cde59fad6624e2863960e62f6544.tar.bz2
Sync of src w/ develop (#3307)
Diffstat (limited to 'src/H5Cimage.c')
-rw-r--r--src/H5Cimage.c783
1 files changed, 91 insertions, 692 deletions
diff --git a/src/H5Cimage.c b/src/H5Cimage.c
index 0d0e42b..96d22d7 100644
--- a/src/H5Cimage.c
+++ b/src/H5Cimage.c
@@ -71,10 +71,6 @@
#define H5C__MDCI_MAX_FD_CHILDREN USHRT_MAX
#define H5C__MDCI_MAX_FD_PARENTS USHRT_MAX
-/* Values for image entry magic field */
-#define H5C_IMAGE_ENTRY_T_MAGIC 0x005CAC08
-#define H5C_IMAGE_ENTRY_T_BAD_MAGIC 0xBeefDead
-
/* Maximum ring allowed in image */
#define H5C_MAX_RING_IN_IMAGE H5C_RING_MDFSM
@@ -89,35 +85,27 @@
#if H5C_COLLECT_CACHE_STATS
/* clang-format off */
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr) \
- (cache_ptr)->images_created++;
+do { \
+ (cache_ptr)->images_created++; \
+} while (0)
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) \
-{ \
+do { \
/* make sure image len is still good */ \
assert((cache_ptr)->image_len > 0); \
(cache_ptr)->images_read++; \
-}
+} while (0)
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr) \
-{ \
+do { \
/* make sure image len is still good */ \
assert((cache_ptr)->image_len > 0); \
(cache_ptr)->images_loaded++; \
(cache_ptr)->last_image_size = (cache_ptr)->image_len; \
-}
-#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty) \
-{ \
- (cache_ptr)->prefetches++; \
- if (dirty) \
- (cache_ptr)->dirty_prefetches++; \
-}
-#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr) \
- (cache_ptr)->prefetch_hits++;
+} while (0)
/* clang-format on */
#else /* H5C_COLLECT_CACHE_STATS */
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_CREATE(cache_ptr)
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr)
#define H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr)
-#define H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, dirty)
-#define H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr)
#endif /* H5C_COLLECT_CACHE_STATS */
/******************/
@@ -135,9 +123,7 @@ static herr_t H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, c
#ifndef NDEBUG /* only used in assertions */
static herr_t H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint8_t **buf,
unsigned entry_num);
-#endif /* NDEBUG */ /* only used in assertions */
-static herr_t H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr,
- H5C_cache_entry_t **fd_children);
+#endif
static herr_t H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t **buf);
static herr_t H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigned entry_num);
static herr_t H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr);
@@ -169,7 +155,6 @@ H5FL_DEFINE(H5C_cache_entry_t);
/*******************/
/*-------------------------------------------------------------------------
- *
* Function: H5C_cache_image_pending()
*
* Purpose: Tests to see if the load of a metadata cache image
@@ -192,7 +177,6 @@ H5C_cache_image_pending(const H5C_t *cache_ptr)
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
ret_value = (cache_ptr->load_image && !cache_ptr->image_loaded);
@@ -230,7 +214,6 @@ H5C_cache_image_status(H5F_t *f, hbool_t *load_ci_ptr, hbool_t *write_ci_ptr)
assert(f->shared);
cache_ptr = f->shared->cache;
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(load_ci_ptr);
assert(write_ci_ptr);
@@ -268,7 +251,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr)
assert(f->shared);
assert(cache_ptr == f->shared->cache);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->image_ctl.generate_image);
assert(cache_ptr->num_entries_in_image > 0);
@@ -314,7 +296,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr)
fake_cache_ptr = (H5C_t *)H5MM_malloc(sizeof(H5C_t));
assert(fake_cache_ptr);
- fake_cache_ptr->magic = H5C__H5C_T_MAGIC;
/* needed for sanity checks */
fake_cache_ptr->image_len = cache_ptr->image_len;
@@ -330,7 +311,6 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr)
assert(fake_cache_ptr->image_entries);
for (u = 0; u < fake_cache_ptr->num_entries_in_image; u++) {
- fake_cache_ptr->image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC;
fake_cache_ptr->image_entries[u].image_ptr = NULL;
/* touch up f->shared->cache to satisfy sanity checks... */
@@ -391,8 +371,8 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr)
fake_cache_ptr->image_entries = (H5C_image_entry_t *)H5MM_xfree(fake_cache_ptr->image_entries);
fake_cache_ptr = (H5C_t *)H5MM_xfree(fake_cache_ptr);
- } /* end block */
-#endif /* NDEBUG */
+ } /* end block */
+#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -420,7 +400,6 @@ H5C__generate_cache_image(H5F_t *f, H5C_t *cache_ptr)
assert(f->shared);
assert(cache_ptr == f->shared->cache);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
/* Construct cache image */
if (H5C__construct_cache_image_buffer(f, cache_ptr) < 0)
@@ -447,375 +426,6 @@ done:
} /* H5C__generate_cache_image() */
/*-------------------------------------------------------------------------
- * Function: H5C__deserialize_prefetched_entry()
- *
- * Purpose: Deserialize the supplied prefetched entry entry, and return
- * a pointer to the deserialized entry in *entry_ptr_ptr.
- * If successful, remove the prefetched entry from the cache,
- * and free it. Insert the deserialized entry into the cache.
- *
- * Note that the on disk image of the entry is not freed --
- * a pointer to it is stored in the deserialized entries'
- * image_ptr field, and its image_up_to_date field is set to
- * TRUE unless the entry is dirtied by the deserialize call.
- *
- * If the prefetched entry is a flush dependency child,
- * destroy that flush dependency prior to calling the
- * deserialize callback. If appropriate, the flush dependency
- * relationship will be recreated by the cache client.
- *
- * If the prefetched entry is a flush dependency parent,
- * destroy the flush dependency relationship with all its
- * children. As all these children must be prefetched entries,
- * recreate these flush dependency relationships with
- * deserialized entry after it is inserted in the cache.
- *
- * Since deserializing a prefetched entry is semantically
- * equivalent to a load, issue an entry loaded nofification
- * if the notify callback is defined.
- *
- * Return: SUCCEED on success, and FAIL on failure.
- *
- * Note that *entry_ptr_ptr is undefined on failure.
- *
- * Programmer: John Mainzer, 8/10/15
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t **entry_ptr_ptr,
- const H5C_class_t *type, haddr_t addr, void *udata)
-{
- hbool_t dirty = FALSE; /* Flag indicating whether thing was
- * dirtied during deserialize
- */
- size_t len; /* Size of image in file */
- void *thing = NULL; /* Pointer to thing loaded */
- H5C_cache_entry_t *pf_entry_ptr; /* pointer to the prefetched entry */
- /* supplied in *entry_ptr_ptr. */
- H5C_cache_entry_t *ds_entry_ptr; /* Alias for thing loaded, as cache
- * entry
- */
- H5C_cache_entry_t **fd_children = NULL; /* Pointer to a dynamically */
- /* allocated array of pointers to */
- /* the flush dependency children of */
- /* the prefetched entry, or NULL if */
- /* that array does not exist. */
- unsigned flush_flags = (H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG);
- int i;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /* sanity checks */
- assert(f);
- assert(f->shared);
- assert(f->shared->cache);
- assert(f->shared->cache == cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
- assert(entry_ptr_ptr);
- assert(*entry_ptr_ptr);
- pf_entry_ptr = *entry_ptr_ptr;
- assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
- assert(pf_entry_ptr->type);
- assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID);
- assert(pf_entry_ptr->prefetched);
- assert(pf_entry_ptr->image_up_to_date);
- assert(pf_entry_ptr->image_ptr);
- assert(pf_entry_ptr->size > 0);
- assert(pf_entry_ptr->addr == addr);
- assert(type);
- assert(type->id == pf_entry_ptr->prefetch_type_id);
- assert(type->mem_type == cache_ptr->class_table_ptr[type->id]->mem_type);
-
- /* verify absence of prohibited or unsupported type flag combinations */
- assert(!(type->flags & H5C__CLASS_SKIP_READS));
-
- /* Can't see how skip reads could be usefully combined with
- * either the speculative read flag. Hence disallow.
- */
- assert(!((type->flags & H5C__CLASS_SKIP_READS) && (type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG)));
- assert(H5_addr_defined(addr));
- assert(type->get_initial_load_size);
- assert(type->deserialize);
-
- /* if *pf_entry_ptr is a flush dependency child, destroy all such
- * relationships now. The client will restore the relationship(s) with
- * the deserialized entry if appropriate.
- */
- assert(pf_entry_ptr->fd_parent_count == pf_entry_ptr->flush_dep_nparents);
- for (i = (int)(pf_entry_ptr->fd_parent_count) - 1; i >= 0; i--) {
- assert(pf_entry_ptr->flush_dep_parent);
- assert(pf_entry_ptr->flush_dep_parent[i]);
- assert(pf_entry_ptr->flush_dep_parent[i]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
- assert(pf_entry_ptr->flush_dep_parent[i]->flush_dep_nchildren > 0);
- assert(pf_entry_ptr->fd_parent_addrs);
- assert(pf_entry_ptr->flush_dep_parent[i]->addr == pf_entry_ptr->fd_parent_addrs[i]);
-
- if (H5C_destroy_flush_dependency(pf_entry_ptr->flush_dep_parent[i], pf_entry_ptr) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "can't destroy pf entry parent flush dependency")
-
- pf_entry_ptr->fd_parent_addrs[i] = HADDR_UNDEF;
- } /* end for */
- assert(pf_entry_ptr->flush_dep_nparents == 0);
-
- /* If *pf_entry_ptr is a flush dependency parent, destroy its flush
- * dependency relationships with all its children (which must be
- * prefetched entries as well).
- *
- * These flush dependency relationships will have to be restored
- * after the deserialized entry is inserted into the cache in order
- * to transfer these relationships to the new entry. Hence save the
- * pointers to the flush dependency children of *pf_enty_ptr for later
- * use.
- */
- if (pf_entry_ptr->fd_child_count > 0) {
- if (NULL == (fd_children = (H5C_cache_entry_t **)H5MM_calloc(
- sizeof(H5C_cache_entry_t **) * (size_t)(pf_entry_ptr->fd_child_count + 1))))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd child ptr array")
-
- if (H5C__destroy_pf_entry_child_flush_deps(cache_ptr, pf_entry_ptr, fd_children) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL,
- "can't destroy pf entry child flush dependency(s).")
- } /* end if */
-
- /* Since the size of the on disk image is known exactly, there is
- * no need for either a call to the get_initial_load_size() callback,
- * or retries if the H5C__CLASS_SPECULATIVE_LOAD_FLAG flag is set.
- * Similarly, there is no need to clamp possible reads beyond
- * EOF.
- */
- len = pf_entry_ptr->size;
-
- /* Deserialize the prefetched on-disk image of the entry into the
- * native memory form
- */
- if (NULL == (thing = type->deserialize(pf_entry_ptr->image_ptr, len, udata, &dirty)))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "Can't deserialize image")
- ds_entry_ptr = (H5C_cache_entry_t *)thing;
-
- /* In general, an entry should be clean just after it is loaded.
- *
- * However, when this code is used in the metadata cache, it is
- * possible that object headers will be dirty at this point, as
- * the deserialize function will alter object headers if necessary to
- * fix an old bug.
- *
- * In the following assert:
- *
- * assert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) );
- *
- * note that type ids 5 & 6 are associated with object headers in the
- * metadata cache.
- *
- * When we get to using H5C for other purposes, we may wish to
- * tighten up the assert so that the loophole only applies to the
- * metadata cache.
- *
- * Note that at present, dirty can't be set to true with prefetched
- * entries. However this may change, so include this functionality
- * against that possibility.
- *
- * Also, note that it is possible for a prefetched entry to be dirty --
- * hence the value assigned to ds_entry_ptr->is_dirty below.
- */
-
- assert((dirty == FALSE) || (type->id == 5 || type->id == 6));
-
- ds_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC;
- ds_entry_ptr->cache_ptr = f->shared->cache;
- ds_entry_ptr->addr = addr;
- ds_entry_ptr->size = len;
- assert(ds_entry_ptr->size < H5C_MAX_ENTRY_SIZE);
- ds_entry_ptr->image_ptr = pf_entry_ptr->image_ptr;
- ds_entry_ptr->image_up_to_date = !dirty;
- ds_entry_ptr->type = type;
- ds_entry_ptr->is_dirty = dirty | pf_entry_ptr->is_dirty;
- ds_entry_ptr->dirtied = FALSE;
- ds_entry_ptr->is_protected = FALSE;
- ds_entry_ptr->is_read_only = FALSE;
- ds_entry_ptr->ro_ref_count = 0;
- ds_entry_ptr->is_pinned = FALSE;
- ds_entry_ptr->in_slist = FALSE;
- ds_entry_ptr->flush_marker = FALSE;
-#ifdef H5_HAVE_PARALLEL
- ds_entry_ptr->clear_on_unprotect = FALSE;
- ds_entry_ptr->flush_immediately = FALSE;
- ds_entry_ptr->coll_access = FALSE;
-#endif /* H5_HAVE_PARALLEL */
- ds_entry_ptr->flush_in_progress = FALSE;
- ds_entry_ptr->destroy_in_progress = FALSE;
-
- ds_entry_ptr->ring = pf_entry_ptr->ring;
-
- /* Initialize flush dependency height fields */
- ds_entry_ptr->flush_dep_parent = NULL;
- ds_entry_ptr->flush_dep_nparents = 0;
- ds_entry_ptr->flush_dep_parent_nalloc = 0;
- ds_entry_ptr->flush_dep_nchildren = 0;
- ds_entry_ptr->flush_dep_ndirty_children = 0;
- ds_entry_ptr->flush_dep_nunser_children = 0;
-
- /* Initialize fields supporting the hash table: */
- ds_entry_ptr->ht_next = NULL;
- ds_entry_ptr->ht_prev = NULL;
- ds_entry_ptr->il_next = NULL;
- ds_entry_ptr->il_prev = NULL;
-
- /* Initialize fields supporting replacement policies: */
- ds_entry_ptr->next = NULL;
- ds_entry_ptr->prev = NULL;
-#if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS
- ds_entry_ptr->aux_next = NULL;
- ds_entry_ptr->aux_prev = NULL;
-#endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */
-#ifdef H5_HAVE_PARALLEL
- pf_entry_ptr->coll_next = NULL;
- pf_entry_ptr->coll_prev = NULL;
-#endif /* H5_HAVE_PARALLEL */
-
- /* Initialize cache image related fields */
- ds_entry_ptr->include_in_image = FALSE;
- ds_entry_ptr->lru_rank = 0;
- ds_entry_ptr->image_dirty = FALSE;
- ds_entry_ptr->fd_parent_count = 0;
- ds_entry_ptr->fd_parent_addrs = NULL;
- ds_entry_ptr->fd_child_count = pf_entry_ptr->fd_child_count;
- ds_entry_ptr->fd_dirty_child_count = 0;
- ds_entry_ptr->image_fd_height = 0;
- ds_entry_ptr->prefetched = FALSE;
- ds_entry_ptr->prefetch_type_id = 0;
- ds_entry_ptr->age = 0;
- ds_entry_ptr->prefetched_dirty = pf_entry_ptr->prefetched_dirty;
-#ifndef NDEBUG /* debugging field */
- ds_entry_ptr->serialization_count = 0;
-#endif /* NDEBUG */
-
- H5C__RESET_CACHE_ENTRY_STATS(ds_entry_ptr);
-
- /* Apply to to the newly deserialized entry */
- if (H5C__tag_entry(cache_ptr, ds_entry_ptr) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, FAIL, "Cannot tag metadata entry")
-
- /* We have successfully deserialized the prefetched entry.
- *
- * Before we return a pointer to the deserialized entry, we must remove
- * the prefetched entry from the cache, discard it, and replace it with
- * the deserialized entry. Note that we do not free the prefetched
- * entries image, as that has been transferred to the deserialized
- * entry.
- *
- * Also note that we have not yet restored any flush dependencies. This
- * must wait until the deserialized entry is inserted in the cache.
- *
- * To delete the prefetched entry from the cache:
- *
- * 1) Set pf_entry_ptr->image_ptr to NULL. Since we have already
- * transferred the buffer containing the image to *ds_entry_ptr,
- * this is not a memory leak.
- *
- * 2) Call H5C__flush_single_entry() with the H5C__FLUSH_INVALIDATE_FLAG
- * and H5C__FLUSH_CLEAR_ONLY_FLAG flags set.
- */
- pf_entry_ptr->image_ptr = NULL;
-
- if (pf_entry_ptr->is_dirty) {
- assert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) ||
- ((!cache_ptr->slist_enabled) && (!pf_entry_ptr->in_slist)));
-
- flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG;
- } /* end if */
-
- if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't expunge prefetched entry")
-
-#ifndef NDEGUG /* verify deletion */
- H5C__SEARCH_INDEX(cache_ptr, addr, pf_entry_ptr, FAIL);
-
- assert(NULL == pf_entry_ptr);
-#endif /* NDEBUG */
-
- /* Insert the deserialized entry into the cache. */
- H5C__INSERT_IN_INDEX(cache_ptr, ds_entry_ptr, FAIL)
-
- assert(!ds_entry_ptr->in_slist);
- if (ds_entry_ptr->is_dirty)
- H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, ds_entry_ptr, FAIL)
-
- H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, ds_entry_ptr, FAIL)
-
- /* Deserializing a prefetched entry is the conceptual equivalent of
- * loading it from file. If the deserialized entry has a notify callback,
- * send an "after load" notice now that the deserialized entry is fully
- * integrated into the cache.
- */
- if (ds_entry_ptr->type->notify &&
- (ds_entry_ptr->type->notify)(H5C_NOTIFY_ACTION_AFTER_LOAD, ds_entry_ptr) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTNOTIFY, FAIL, "can't notify client about entry loaded into cache")
-
- /* Restore flush dependencies with the flush dependency children of
- * of the prefetched entry. Note that we must protect *ds_entry_ptr
- * before the call to avoid triggering sanity check failures, and
- * then unprotect it afterwards.
- */
- i = 0;
- if (fd_children != NULL) {
- H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, ds_entry_ptr, FAIL)
- ds_entry_ptr->is_protected = TRUE;
- while (fd_children[i] != NULL) {
- /* Sanity checks */
- assert((fd_children[i])->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
- assert((fd_children[i])->prefetched);
- assert((fd_children[i])->fd_parent_count > 0);
- assert((fd_children[i])->fd_parent_addrs);
-
-#ifndef NDEBUG
- {
- int j;
- hbool_t found;
-
- j = 0;
- found = FALSE;
- while ((j < (int)((fd_children[i])->fd_parent_count)) && (!found)) {
- if ((fd_children[i])->fd_parent_addrs[j] == ds_entry_ptr->addr)
- found = TRUE;
-
- j++;
- } /* end while */
- assert(found);
- }
-#endif /* NDEBUG */
-
- if (H5C_create_flush_dependency(ds_entry_ptr, fd_children[i]) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore child flush dependency")
-
- i++;
- } /* end while */
-
- H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, ds_entry_ptr, FAIL);
- ds_entry_ptr->is_protected = FALSE;
- } /* end if ( fd_children != NULL ) */
- assert((unsigned)i == ds_entry_ptr->fd_child_count);
-
- ds_entry_ptr->fd_child_count = 0;
- H5C__UPDATE_STATS_FOR_PREFETCH_HIT(cache_ptr)
-
- /* finally, pass ds_entry_ptr back to the caller */
- *entry_ptr_ptr = ds_entry_ptr;
-
-done:
- if (fd_children)
- fd_children = (H5C_cache_entry_t **)H5MM_xfree((void *)fd_children);
-
- /* Release resources on error */
- if (FAIL == ret_value)
- if (thing && type->free_icr(thing) < 0)
- HDONE_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "free_icr callback failed")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5C__deserialize_prefetched_entry() */
-
-/*-------------------------------------------------------------------------
* Function: H5C__free_image_entries_array
*
* Purpose: If the image entries array exists, free the image
@@ -836,7 +446,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr)
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->image_ctl.generate_image);
assert(cache_ptr->index_len == 0);
@@ -853,7 +462,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr)
/* Sanity checks */
assert(ie_ptr);
- assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC);
assert(ie_ptr->image_ptr);
/* Free the parent addrs array if appropriate */
@@ -867,9 +475,6 @@ H5C__free_image_entries_array(H5C_t *cache_ptr)
/* Free the image */
ie_ptr->image_ptr = H5MM_xfree(ie_ptr->image_ptr);
-
- /* Set magic field to bad magic so we can detect freed entries */
- ie_ptr->magic = H5C_IMAGE_ENTRY_T_BAD_MAGIC;
} /* end for */
/* Free the image entries array */
@@ -880,7 +485,7 @@ H5C__free_image_entries_array(H5C_t *cache_ptr)
} /* H5C__free_image_entries_array() */
/*-------------------------------------------------------------------------
- * Function: H5C_get_cache_image_config
+ * Function: H5C__get_cache_image_config
*
* Purpose: Copy the current configuration for cache image generation
* on file close into the instance of H5C_cache_image_ctl_t
@@ -891,13 +496,13 @@ H5C__free_image_entries_array(H5C_t *cache_ptr)
*-------------------------------------------------------------------------
*/
herr_t
-H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr)
+H5C__get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_PACKAGE
- if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC))
+ if (cache_ptr == NULL)
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry")
if (config_ptr == NULL)
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad config_ptr on entry")
@@ -906,72 +511,7 @@ H5C_get_cache_image_config(const H5C_t *cache_ptr, H5C_cache_image_ctl_t *config
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5C_get_cache_image_config() */
-
-/*-------------------------------------------------------------------------
- * Function: H5C_image_stats
- *
- * Purpose: Prints statistics specific to the cache image.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: John Mainzer
- * 10/26/15
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-#if H5C_COLLECT_CACHE_STATS
-H5C_image_stats(H5C_t *cache_ptr, hbool_t print_header)
-#else /* H5C_COLLECT_CACHE_STATS */
-H5C_image_stats(H5C_t *cache_ptr, hbool_t H5_ATTR_UNUSED print_header)
-#endif /* H5C_COLLECT_CACHE_STATS */
-{
-#if H5C_COLLECT_CACHE_STATS
- int i;
- int64_t total_hits = 0;
- int64_t total_misses = 0;
- double hit_rate;
- double prefetch_use_rate;
-#endif /* H5C_COLLECT_CACHE_STATS */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- if (!cache_ptr || cache_ptr->magic != H5C__H5C_T_MAGIC)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr")
-
-#if H5C_COLLECT_CACHE_STATS
- for (i = 0; i <= cache_ptr->max_type_id; i++) {
- total_hits += cache_ptr->hits[i];
- total_misses += cache_ptr->misses[i];
- } /* end for */
-
- if ((total_hits > 0) || (total_misses > 0))
- hit_rate = 100.0 * ((double)(total_hits)) / ((double)(total_hits + total_misses));
- else
- hit_rate = 0.0;
-
- if (cache_ptr->prefetches > 0)
- prefetch_use_rate = 100.0 * ((double)(cache_ptr->prefetch_hits)) / ((double)(cache_ptr->prefetches));
- else
- prefetch_use_rate = 0.0;
-
- if (print_header) {
- fprintf(stdout, "\nhit prefetches prefetch image pf hit\n");
- fprintf(stdout, "rate: total: dirty: hits: flshs: evct: size: rate:\n");
- } /* end if */
-
- fprintf(stdout, "%3.1lf %5lld %5lld %5lld %5lld %5lld %5lld %3.1lf\n", hit_rate,
- (long long)(cache_ptr->prefetches), (long long)(cache_ptr->dirty_prefetches),
- (long long)(cache_ptr->prefetch_hits), (long long)(cache_ptr->flushes[H5AC_PREFETCHED_ENTRY_ID]),
- (long long)(cache_ptr->evictions[H5AC_PREFETCHED_ENTRY_ID]),
- (long long)(cache_ptr->last_image_size), prefetch_use_rate);
-#endif /* H5C_COLLECT_CACHE_STATS */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5C_image_stats() */
+} /* H5C__get_cache_image_config() */
/*-------------------------------------------------------------------------
* Function: H5C__read_cache_image
@@ -1002,8 +542,7 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr)
H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr;
int mpi_result;
- if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) {
- assert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC));
+ if (NULL == aux_ptr || aux_ptr->mpi_rank == 0) {
#endif /* H5_HAVE_PARALLEL */
/* Read the buffer (if serial access, or rank 0 of parallel access) */
@@ -1014,7 +553,7 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr)
cache_ptr->image_buffer) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_READERROR, FAIL, "Can't read metadata cache image block")
- H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr)
+ H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr);
#ifdef H5_HAVE_PARALLEL
if (aux_ptr) {
@@ -1064,7 +603,6 @@ H5C__load_cache_image(H5F_t *f)
assert(f->shared);
cache_ptr = f->shared->cache;
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
/* If the image address is defined, load the image, decode it,
* and insert its contents into the metadata cache.
@@ -1098,7 +636,7 @@ H5C__load_cache_image(H5F_t *f)
/* Update stats -- must do this now, as we are about
* to discard the size of the cache image.
*/
- H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr)
+ H5C__UPDATE_STATS_FOR_CACHE_IMAGE_LOAD(cache_ptr);
cache_ptr->image_loaded = TRUE;
} /* end if */
@@ -1156,7 +694,6 @@ H5C_load_cache_image_on_next_protect(H5F_t *f, haddr_t addr, hsize_t len, hbool_
assert(f->shared);
cache_ptr = f->shared->cache;
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
/* Set information needed to load cache image */
cache_ptr->image_addr = addr;
@@ -1279,7 +816,6 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
assert(f->shared->cache);
cache_ptr = f->shared->cache;
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(image_generated);
/* If the file is opened and closed without any access to
@@ -1494,8 +1030,8 @@ H5C__prep_image_for_file_close(H5F_t *f, hbool_t *image_generated)
HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "can't setup image entries array.")
/* Sort the entries */
- HDqsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image,
- sizeof(H5C_image_entry_t), H5C__image_entry_cmp);
+ qsort(cache_ptr->image_entries, (size_t)cache_ptr->num_entries_in_image,
+ sizeof(H5C_image_entry_t), H5C__image_entry_cmp);
} /* end if */
else { /* cancel creation of metadata cache image */
assert(cache_ptr->image_entries == NULL);
@@ -1559,7 +1095,7 @@ H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl
assert(f->shared->cache == f->shared->cache);
/* Check arguments */
- if ((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC))
+ if (cache_ptr == NULL)
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache_ptr on entry")
/* Validate the config: */
@@ -1745,7 +1281,6 @@ H5C__decode_cache_image_header(const H5F_t *f, H5C_t *cache_ptr, const uint8_t *
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(buf);
assert(*buf);
@@ -1842,13 +1377,11 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint
assert(f->shared);
assert(cache_ptr == f->shared->cache);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(buf);
assert(*buf);
assert(entry_num < cache_ptr->num_entries_in_image);
ie_ptr = &(cache_ptr->image_entries[entry_num]);
assert(ie_ptr);
- assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC);
/* Get pointer to buffer */
p = *buf;
@@ -1893,7 +1426,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint
assert((in_lru && lru_rank >= 0) || (!in_lru && lru_rank == -1));
/* Decode entry offset */
- H5_addr_decode(f, &p, &addr);
+ H5F_addr_decode(f, &p, &addr);
if (!H5_addr_defined(addr))
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid entry offset")
@@ -1916,7 +1449,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for fd parent addrs buffer")
for (i = 0; i < fd_parent_count; i++) {
- H5_addr_decode(f, &p, &(fd_parent_addrs[i]));
+ H5F_addr_decode(f, &p, &(fd_parent_addrs[i]));
if (!H5_addr_defined(fd_parent_addrs[i]))
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "invalid flush dependency parent offset")
} /* end for */
@@ -1954,135 +1487,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5C__decode_cache_image_entry() */
-#endif /* NDEBUG */
-
-/*-------------------------------------------------------------------------
- * Function: H5C__destroy_pf_entry_child_flush_deps()
- *
- * Purpose: Destroy all flush dependencies in this the supplied
- * prefetched entry is the parent. Note that the children
- * in these flush dependencies must be prefetched entries as
- * well.
- *
- * As this action is part of the process of transferring all
- * such flush dependencies to the deserialized version of the
- * prefetched entry, ensure that the data necessary to complete
- * the transfer is retained.
- *
- * Note: The current implementation of this function is
- * quite inefficient -- mostly due to the current
- * implementation of flush dependencies. This should
- * be fixed at some point.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: John Mainzer
- * 8/11/15
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5C__destroy_pf_entry_child_flush_deps(H5C_t *cache_ptr, H5C_cache_entry_t *pf_entry_ptr,
- H5C_cache_entry_t **fd_children)
-{
- H5C_cache_entry_t *entry_ptr;
- unsigned entries_visited = 0;
- int fd_children_found = 0;
- hbool_t found;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /* Sanity checks */
- assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
- assert(pf_entry_ptr);
- assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
- assert(pf_entry_ptr->type);
- assert(pf_entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID);
- assert(pf_entry_ptr->prefetched);
- assert(pf_entry_ptr->fd_child_count > 0);
- assert(fd_children);
-
- /* Scan each entry on the index list */
- entry_ptr = cache_ptr->il_head;
- while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
- /* Here we look at entry_ptr->flush_dep_nparents and not
- * entry_ptr->fd_parent_count as it is possible that some
- * or all of the prefetched flush dependency child relationships
- * have already been destroyed.
- */
- if (entry_ptr->prefetched && (entry_ptr->flush_dep_nparents > 0)) {
- unsigned u; /* Local index variable */
-
- /* Re-init */
- u = 0;
- found = FALSE;
-
- /* Sanity checks */
- assert(entry_ptr->type);
- assert(entry_ptr->type->id == H5AC_PREFETCHED_ENTRY_ID);
- assert(entry_ptr->fd_parent_count >= entry_ptr->flush_dep_nparents);
- assert(entry_ptr->fd_parent_addrs);
- assert(entry_ptr->flush_dep_parent);
-
- /* Look for correct entry */
- while (!found && (u < entry_ptr->fd_parent_count)) {
- /* Sanity check entry */
- assert(entry_ptr->flush_dep_parent[u]);
- assert(entry_ptr->flush_dep_parent[u]->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
- /* Correct entry? */
- if (pf_entry_ptr == entry_ptr->flush_dep_parent[u])
- found = TRUE;
-
- u++;
- } /* end while */
-
- if (found) {
- assert(NULL == fd_children[fd_children_found]);
-
- /* Remove flush dependency */
- fd_children[fd_children_found] = entry_ptr;
- fd_children_found++;
- if (H5C_destroy_flush_dependency(pf_entry_ptr, entry_ptr) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL,
- "can't destroy pf entry child flush dependency")
-
-#ifndef NDEBUG
- /* Sanity check -- verify that the address of the parent
- * appears in entry_ptr->fd_parent_addrs. Must do a search,
- * as with flush dependency creates and destroys,
- * entry_ptr->fd_parent_addrs and entry_ptr->flush_dep_parent
- * can list parents in different order.
- */
- found = FALSE;
- u = 0;
- while (!found && u < entry_ptr->fd_parent_count) {
- if (pf_entry_ptr->addr == entry_ptr->fd_parent_addrs[u])
- found = TRUE;
- u++;
- } /* end while */
- assert(found);
-#endif /* NDEBUG */
- } /* end if */
- } /* end if */
-
- entries_visited++;
- entry_ptr = entry_ptr->il_next;
- } /* end while */
-
- /* Post-op sanity checks */
- assert(NULL == fd_children[fd_children_found]);
- assert((unsigned)fd_children_found == pf_entry_ptr->fd_child_count);
- assert(entries_visited == cache_ptr->index_len);
- assert(!pf_entry_ptr->is_pinned);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* H5C__destroy_pf_entry_child_flush_deps() */
+#endif
/*-------------------------------------------------------------------------
* Function: H5C__encode_cache_image_header()
@@ -2108,7 +1513,6 @@ H5C__encode_cache_image_header(const H5F_t *f, const H5C_t *cache_ptr, uint8_t *
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->image_ctl.generate_image);
assert(cache_ptr->index_len == 0);
@@ -2184,7 +1588,6 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne
assert(f->shared);
assert(cache_ptr == f->shared->cache);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->image_ctl.generate_image);
assert(cache_ptr->index_len == 0);
@@ -2192,7 +1595,6 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne
assert(*buf);
assert(entry_num < cache_ptr->num_entries_in_image);
ie_ptr = &(cache_ptr->image_entries[entry_num]);
- assert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC);
/* Get pointer to buffer to encode into */
p = *buf;
@@ -2238,7 +1640,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne
INT32ENCODE(p, ie_ptr->lru_rank);
/* Encode entry offset */
- H5_addr_encode(f, &p, ie_ptr->addr);
+ H5F_addr_encode(f, &p, ie_ptr->addr);
/* Encode entry length */
H5F_ENCODE_LENGTH(f, p, ie_ptr->size);
@@ -2249,7 +1651,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne
/* Encode dependency parent offsets -- if any */
for (u = 0; u < ie_ptr->fd_parent_count; u++)
- H5_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]);
+ H5F_addr_encode(f, &p, ie_ptr->fd_parent_addrs[u]);
/* Copy entry image */
H5MM_memcpy(p, ie_ptr->image_ptr, ie_ptr->size);
@@ -2312,18 +1714,19 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
{
H5C_cache_entry_t *entry_ptr;
H5C_cache_entry_t *parent_ptr;
- unsigned entries_removed_from_image = 0;
- unsigned external_parent_fd_refs_removed = 0;
- unsigned external_child_fd_refs_removed = 0;
- hbool_t done = FALSE;
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED;
+#ifndef NDEBUG
+ unsigned entries_removed_from_image = 0;
+ unsigned external_parent_fd_refs_removed = 0;
+ unsigned external_child_fd_refs_removed = 0;
+#endif
+ hbool_t done = FALSE;
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
/* sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
/* Remove from the cache image all dirty entries that are
* flush dependency children of dirty entries that are not in the
@@ -2337,8 +1740,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
done = TRUE;
entry_ptr = cache_ptr->il_head;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
/* Should this entry be in the image */
if (entry_ptr->image_dirty && entry_ptr->include_in_image && (entry_ptr->fd_parent_count > 0)) {
assert(entry_ptr->flush_dep_parent != NULL);
@@ -2346,14 +1747,15 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
parent_ptr = entry_ptr->flush_dep_parent[u];
/* Sanity check parent */
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->ring == parent_ptr->ring);
if (parent_ptr->is_dirty && !parent_ptr->include_in_image &&
entry_ptr->include_in_image) {
/* Must remove child from image -- only do this once */
+#ifndef NDEBUG
entries_removed_from_image++;
+#endif
entry_ptr->include_in_image = FALSE;
} /* end if */
} /* for */
@@ -2383,7 +1785,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
parent_ptr = entry_ptr->flush_dep_parent[u];
/* Sanity check parent */
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->ring == parent_ptr->ring);
if (parent_ptr->include_in_image) {
@@ -2396,7 +1797,9 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
parent_ptr->fd_dirty_child_count--;
} /* end if */
+#ifndef NDEBUG
external_child_fd_refs_removed++;
+#endif
} /* end if */
} /* for */
} /* end if */
@@ -2410,7 +1813,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
parent_ptr = entry_ptr->flush_dep_parent[u];
/* Sanity check parent */
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->ring == parent_ptr->ring);
if (!parent_ptr->include_in_image) {
@@ -2421,7 +1823,9 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
assert(parent_ptr->addr == entry_ptr->fd_parent_addrs[u]);
entry_ptr->fd_parent_addrs[u] = HADDR_UNDEF;
+#ifndef NDEBUG
external_parent_fd_refs_removed++;
+#endif
} /* end if */
} /* for */
@@ -2477,7 +1881,6 @@ H5C__prep_for_file_close__compute_fd_heights(const H5C_t *cache_ptr)
for (u = 0; u < entry_ptr->fd_parent_count; u++) {
parent_ptr = entry_ptr->flush_dep_parent[u];
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= 0)
H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, 1);
} /* end for */
@@ -2542,7 +1945,6 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr,
/* Sanity checks */
assert(entry_ptr);
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->include_in_image);
assert((entry_ptr->image_fd_height == 0) || (entry_ptr->image_fd_height < fd_height));
assert(((fd_height == 0) && (entry_ptr->fd_child_count == 0)) ||
@@ -2557,7 +1959,6 @@ H5C__prep_for_file_close__compute_fd_heights_real(H5C_cache_entry_t *entry_ptr,
H5C_cache_entry_t *parent_ptr;
parent_ptr = entry_ptr->flush_dep_parent[u];
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
if (parent_ptr->include_in_image && parent_ptr->image_fd_height <= fd_height)
H5C__prep_for_file_close__compute_fd_heights_real(parent_ptr, fd_height + 1);
@@ -2582,16 +1983,17 @@ static herr_t
H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
{
H5C_cache_entry_t *entry_ptr;
- H5C_image_entry_t *image_entries = NULL;
- uint32_t entries_visited = 0;
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5C_image_entry_t *image_entries = NULL;
+#ifndef NDEBUG
+ uint32_t entries_visited = 0;
+#endif
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->pl_len == 0);
assert(cache_ptr->num_entries_in_image > 0);
@@ -2604,7 +2006,6 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
/* Initialize (non-zero/NULL/FALSE) fields */
for (u = 0; u <= cache_ptr->num_entries_in_image; u++) {
- image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC;
image_entries[u].addr = HADDR_UNDEF;
image_entries[u].ring = H5C_RING_UNDEFINED;
image_entries[u].type_id = -1;
@@ -2614,8 +2015,6 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
u = 0;
entry_ptr = cache_ptr->il_head;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
if (entry_ptr->include_in_image) {
/* Since we have already serialized the cache, the following
* should hold.
@@ -2668,7 +2067,9 @@ H5C__prep_for_file_close__setup_image_entries_array(H5C_t *cache_ptr)
assert(u <= cache_ptr->num_entries_in_image);
} /* end if */
+#ifndef NDEBUG
entries_visited++;
+#endif
entry_ptr = entry_ptr->il_next;
} /* end while */
@@ -2718,14 +2119,16 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
{
H5C_cache_entry_t *entry_ptr;
hbool_t include_in_image;
- unsigned entries_visited = 0;
- int lru_rank = 1;
- uint32_t num_entries_tentatively_in_image = 0;
- uint32_t num_entries_in_image = 0;
- size_t image_len;
- size_t entry_header_len;
- size_t fd_parents_list_len;
- herr_t ret_value = SUCCEED; /* Return value */
+ int lru_rank = 1;
+#ifndef NDEBUG
+ unsigned entries_visited = 0;
+ uint32_t num_entries_tentatively_in_image = 0;
+#endif
+ uint32_t num_entries_in_image = 0;
+ size_t image_len;
+ size_t entry_header_len;
+ size_t fd_parents_list_len;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -2734,7 +2137,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
assert(f->shared);
assert(f->shared->sblock);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
assert(cache_ptr->pl_len == 0);
@@ -2747,8 +2149,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
/* Scan each entry on the index list */
entry_ptr = cache_ptr->il_head;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
/* Since we have already serialized the cache, the following
* should hold.
*/
@@ -2826,10 +2226,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
entry_ptr->fd_dirty_child_count = entry_ptr->flush_dep_ndirty_children;
} /* end if */
+#ifndef NDEBUG
num_entries_tentatively_in_image++;
+#endif
} /* end if */
+#ifndef NDEBUG
entries_visited++;
+#endif
entry_ptr = entry_ptr->il_next;
} /* end while */
assert(entries_visited == cache_ptr->index_len);
@@ -2860,15 +2264,15 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
if (H5C__prep_for_file_close__compute_fd_heights(cache_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "computation of flush dependency heights failed?!?")
- /* At this point, all entries that will appear in the cache
- * image should be marked correctly. Compute the size of the
- * cache image.
- */
+ /* At this point, all entries that will appear in the cache
+ * image should be marked correctly. Compute the size of the
+ * cache image.
+ */
+#ifndef NDEBUG
entries_visited = 0;
- entry_ptr = cache_ptr->il_head;
+#endif
+ entry_ptr = cache_ptr->il_head;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
-
if (entry_ptr->include_in_image) {
if (entry_ptr->fd_parent_count > 0)
fd_parents_list_len = (size_t)(H5F_SIZEOF_ADDR(f) * entry_ptr->fd_parent_count);
@@ -2879,7 +2283,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
num_entries_in_image++;
} /* end if */
+#ifndef NDEBUG
entries_visited++;
+#endif
entry_ptr = entry_ptr->il_next;
} /* end while */
assert(entries_visited == cache_ptr->index_len);
@@ -2897,7 +2303,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
#endif
cache_ptr->num_entries_in_image = num_entries_in_image;
- entries_visited = 0;
+#ifndef NDEBUG
+ entries_visited = 0;
+#endif
/* Now scan the LRU list to set the lru_rank fields of all entries
* on the LRU.
@@ -2911,7 +2319,6 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
*/
entry_ptr = cache_ptr->LRU_head_ptr;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->type != NULL);
/* to avoid confusion, don't set lru_rank on epoch markers.
@@ -2930,7 +2337,9 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr)
lru_rank++;
} /* end else-if */
+#ifndef NDEBUG
entries_visited++;
+#endif
entry_ptr = entry_ptr->next;
} /* end while */
assert(entries_visited == cache_ptr->LRU_list_len);
@@ -2971,7 +2380,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
assert(f->shared);
assert(cache_ptr == f->shared->cache);
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->image_buffer);
assert(cache_ptr->image_len > 0);
@@ -3003,16 +2411,16 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
*/
/* Insert the prefetched entry in the index */
- H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL)
+ H5C__INSERT_IN_INDEX(cache_ptr, pf_entry_ptr, FAIL);
/* If dirty, insert the entry into the slist. */
if (pf_entry_ptr->is_dirty)
- H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL)
+ H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, pf_entry_ptr, FAIL);
/* Append the entry to the LRU */
- H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL)
+ H5C__UPDATE_RP_FOR_INSERT_APPEND(cache_ptr, pf_entry_ptr, FAIL);
- H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty)
+ H5C__UPDATE_STATS_FOR_PREFETCH(cache_ptr, pf_entry_ptr->is_dirty);
/* If the prefetched entry is the child in one or more flush
* dependency relationships, recreate those flush dependencies.
@@ -3024,19 +2432,18 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
/* Find the parent entry */
parent_ptr = NULL;
- H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL)
+ H5C__SEARCH_INDEX(cache_ptr, pf_entry_ptr->fd_parent_addrs[v], parent_ptr, FAIL);
if (parent_ptr == NULL)
HGOTO_ERROR(H5E_CACHE, H5E_NOTFOUND, FAIL, "fd parent not in cache?!?")
/* Sanity checks */
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(parent_ptr->addr == pf_entry_ptr->fd_parent_addrs[v]);
assert(parent_ptr->lru_rank == -1);
/* Must protect parent entry to set up a flush dependency.
* Do this now, and then uprotect when done.
*/
- H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL)
+ H5C__UPDATE_RP_FOR_PROTECT(cache_ptr, parent_ptr, FAIL);
parent_ptr->is_protected = TRUE;
/* Setup the flush dependency */
@@ -3044,7 +2451,7 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "Can't restore flush dependency")
/* And now unprotect */
- H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL)
+ H5C__UPDATE_RP_FOR_UNPROTECT(cache_ptr, parent_ptr, FAIL);
parent_ptr->is_protected = FALSE;
} /* end for */
} /* end for */
@@ -3055,7 +2462,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
*/
pf_entry_ptr = cache_ptr->il_head;
while (pf_entry_ptr != NULL) {
- assert(pf_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert((pf_entry_ptr->prefetched && pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY) ||
(!pf_entry_ptr->prefetched && pf_entry_ptr->type != H5AC_PREFETCHED_ENTRY));
if (pf_entry_ptr->type == H5AC_PREFETCHED_ENTRY)
@@ -3064,7 +2470,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
for (v = 0; v < pf_entry_ptr->fd_parent_count; v++) {
parent_ptr = pf_entry_ptr->flush_dep_parent[v];
assert(parent_ptr);
- assert(parent_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(pf_entry_ptr->fd_parent_addrs);
assert(pf_entry_ptr->fd_parent_addrs[v] == parent_ptr->addr);
assert(parent_ptr->flush_dep_nchildren > 0);
@@ -3089,7 +2494,6 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
i = -1;
entry_ptr = cache_ptr->LRU_head_ptr;
while (entry_ptr != NULL) {
- assert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
assert(entry_ptr->type != NULL);
if (entry_ptr->prefetched) {
@@ -3111,8 +2515,8 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr)
* we add code to store and restore adaptive resize status.
*/
assert(lru_rank_holes <= H5C__MAX_EPOCH_MARKERS);
- } /* end block */
-#endif /* NDEBUG */
+ } /* end block */
+#endif
/* Check to see if the cache is oversize, and evict entries as
* necessary to remain within limits.
@@ -3160,7 +2564,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
hbool_t in_lru = FALSE;
hbool_t is_fd_parent = FALSE;
hbool_t is_fd_child = FALSE;
-#endif /* NDEBUG */ /* only used in assertions */
+#endif
const uint8_t *p;
hbool_t file_is_rw;
H5C_cache_entry_t *ret_value = NULL; /* Return value */
@@ -3169,7 +2573,6 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
/* Sanity checks */
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->num_entries_in_image > 0);
assert(buf && *buf);
@@ -3197,7 +2600,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
is_fd_parent = TRUE;
if (flags & H5C__MDCI_ENTRY_IS_FD_CHILD_FLAG)
is_fd_child = TRUE;
-#endif /* NDEBUG */ /* only used in assertions */
+#endif
/* Force dirty entries to clean if the file read only -- must do
* this as otherwise the cache will attempt to write them on file
@@ -3243,7 +2646,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
assert((in_lru && pf_entry_ptr->lru_rank >= 0) || (!in_lru && pf_entry_ptr->lru_rank == -1));
/* Decode entry offset */
- H5_addr_decode(f, &p, &pf_entry_ptr->addr);
+ H5F_addr_decode(f, &p, &pf_entry_ptr->addr);
if (!H5_addr_defined(pf_entry_ptr->addr))
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid entry offset")
@@ -3267,7 +2670,7 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for fd parent addrs buffer")
for (u = 0; u < pf_entry_ptr->fd_parent_count; u++) {
- H5_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u]));
+ H5F_addr_decode(f, &p, &(pf_entry_ptr->fd_parent_addrs[u]));
if (!H5_addr_defined(pf_entry_ptr->fd_parent_addrs[u]))
HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "invalid flush dependency parent offset")
} /* end for */
@@ -3286,7 +2689,6 @@ H5C__reconstruct_cache_entry(const H5F_t *f, H5C_t *cache_ptr, const uint8_t **b
/* Initialize the rest of the fields in the prefetched entry */
/* (Only need to set non-zero/NULL/FALSE fields, due to calloc() above) */
- pf_entry_ptr->magic = H5C__H5C_CACHE_ENTRY_T_MAGIC;
pf_entry_ptr->cache_ptr = cache_ptr;
pf_entry_ptr->image_up_to_date = TRUE;
pf_entry_ptr->type = H5AC_PREFETCHED_ENTRY;
@@ -3341,7 +2743,6 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create)
assert(f->shared->cache);
cache_ptr = f->shared->cache;
assert(cache_ptr);
- assert(cache_ptr->magic == H5C__H5C_T_MAGIC);
assert(cache_ptr->close_warning_received);
/* Write data into the metadata cache image superblock extension message.
@@ -3353,8 +2754,7 @@ H5C__write_cache_image_superblock_msg(H5F_t *f, hbool_t create)
if (cache_ptr->aux_ptr) { /* we have multiple processes */
H5AC_aux_t *aux_ptr;
- aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr;
- assert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC);
+ aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr;
mdci_msg.size = aux_ptr->p0_image_len;
} /* end if */
else
@@ -3398,8 +2798,7 @@ H5C__write_cache_image(H5F_t *f, const H5C_t *cache_ptr)
{
H5AC_aux_t *aux_ptr = (H5AC_aux_t *)cache_ptr->aux_ptr;
- if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) {
- assert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC));
+ if (NULL == aux_ptr || aux_ptr->mpi_rank == 0) {
#endif /* H5_HAVE_PARALLEL */
/* Write the buffer (if serial access, or rank 0 for parallel access) */