summaryrefslogtreecommitdiffstats
path: root/src/H5C.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-02-10 17:55:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-02-10 17:55:55 (GMT)
commitc8a6c6030a768952bc4161b2bf30c948b8b58723 (patch)
tree064e57faf3f85c030d70900c3354fee2fbffd8ac /src/H5C.c
parentf1283d59b061cde641f2c24d23f01efbca46ad2f (diff)
downloadhdf5-c8a6c6030a768952bc4161b2bf30c948b8b58723.zip
hdf5-c8a6c6030a768952bc4161b2bf30c948b8b58723.tar.gz
hdf5-c8a6c6030a768952bc4161b2bf30c948b8b58723.tar.bz2
[svn-r29077] Description:
Normalize against the trunk, in preparation for final merge. Tested on: MacOSX/64 10.11.3 (amazon) w/serial & parallel (h5committest not required on this branch)
Diffstat (limited to 'src/H5C.c')
-rw-r--r--src/H5C.c527
1 files changed, 153 insertions, 374 deletions
diff --git a/src/H5C.c b/src/H5C.c
index 100fbe0..37b0df2 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -93,7 +93,6 @@
#include "H5MFprivate.h" /* File memory management */
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
-#include "H5SLprivate.h" /* Skip lists */
/****************/
@@ -182,7 +181,7 @@ static herr_t H5C_mark_tagged_entries(H5C_t * cache_ptr,
static herr_t H5C_flush_marked_entries(H5F_t * f,
hid_t dxpl_id);
-static herr_t H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
+static herr_t H5C__generate_image(const H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
hid_t dxpl_id, int64_t *entry_size_change_ptr);
#if H5C_DO_TAGGING_SANITY_CHECKS
@@ -225,6 +224,9 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
/* Declare a free list to manage the H5C_t struct */
H5FL_DEFINE_STATIC(H5C_t);
+/* Declare extern free list to manage the H5C_collective_write_t struct */
+H5FL_EXTERN(H5C_collective_write_t);
+
/****************************************************************************
@@ -1006,7 +1008,7 @@ H5C_expunge_entry(H5F_t *f, hid_t dxpl_id, const H5C_class_t *type,
flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG;
if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, flush_flags, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_flush_single_entry() failed.")
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "can't flush entry")
#if H5C_DO_SANITY_CHECKS
if ( entry_was_dirty )
@@ -1913,8 +1915,10 @@ H5C_insert_entry(H5F_t * f,
entry_ptr->aux_next = NULL;
entry_ptr->aux_prev = NULL;
+#ifdef H5_HAVE_PARALLEL
entry_ptr->coll_next = NULL;
entry_ptr->coll_prev = NULL;
+#endif /* H5_HAVE_PARALLEL */
H5C__RESET_CACHE_ENTRY_STATS(entry_ptr)
@@ -2041,19 +2045,18 @@ H5C_insert_entry(H5F_t * f,
/* Make sure the size of the collective entries in the cache remain in check */
if(H5P_USER_TRUE == f->coll_md_read) {
- if(cache_ptr->max_cache_size*80 < cache_ptr->coll_list_size*100) {
- if(H5C_clear_coll_entries(cache_ptr, 1) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.")
+ if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) {
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries")
} /* end if */
} /* end if */
else {
- if(cache_ptr->max_cache_size*40 < cache_ptr->coll_list_size*100) {
- if(H5C_clear_coll_entries(cache_ptr, 1) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.")
+ if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) {
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries")
} /* end if */
} /* end else */
} /* end if */
- entry_ptr->ind_access_while_coll = FALSE;
#endif
done:
@@ -2724,52 +2727,52 @@ H5C_protect(H5F_t * f,
the entry in their cache still have to participate in the
bcast. */
#ifdef H5_HAVE_PARALLEL
- if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && coll_access &&
- !(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) {
- MPI_Comm comm; /* File MPI Communicator */
- int mpi_code; /* MPI error code */
- int buf_size;
+ if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && coll_access) {
+ if(!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) {
+ MPI_Comm comm; /* File MPI Communicator */
+ int mpi_code; /* MPI error code */
+ int buf_size;
- if(MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed")
+ if(MPI_COMM_NULL == (comm = H5F_mpi_get_comm(f)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "get_comm request failed")
- if(entry_ptr->image_ptr == NULL) {
- int mpi_rank;
- size_t image_size;
+ if(entry_ptr->image_ptr == NULL) {
+ int mpi_rank;
+ size_t image_size;
- if((mpi_rank = H5F_mpi_get_rank(f)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank")
+ if((mpi_rank = H5F_mpi_get_rank(f)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "Can't get MPI rank")
- if(entry_ptr->compressed)
- image_size = entry_ptr->compressed_size;
- else
- image_size = entry_ptr->size;
- HDassert(image_size > 0);
+ if(entry_ptr->compressed)
+ image_size = entry_ptr->compressed_size;
+ else
+ image_size = entry_ptr->size;
+ HDassert(image_size > 0);
- if(NULL == (entry_ptr->image_ptr = H5MM_malloc(image_size + H5C_IMAGE_EXTRA_SPACE)))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer")
+ if(NULL == (entry_ptr->image_ptr = H5MM_malloc(image_size + H5C_IMAGE_EXTRA_SPACE)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + image_size,
- H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
+ HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + image_size,
+ H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
- if(0 == mpi_rank)
- if(H5C__generate_image(f, cache_ptr, entry_ptr, dxpl_id, NULL) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "Can't get Image")
- } /* end if */
-
- HDassert(entry_ptr->image_ptr);
-
- H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t);
- if(MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm)))
- HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code)
+ if(0 == mpi_rank)
+ if(H5C__generate_image(f, cache_ptr, entry_ptr, dxpl_id, NULL) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't generate entry's image")
+ } /* end if */
+ HDassert(entry_ptr->image_ptr);
- entry_ptr->coll_access = TRUE;
+ H5_CHECKED_ASSIGN(buf_size, int, entry_ptr->size, size_t);
+ if(MPI_SUCCESS != (mpi_code = MPI_Bcast(entry_ptr->image_ptr, buf_size, MPI_BYTE, 0, comm)))
+ HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code)
- H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL)
+ /* Mark the entry as collective and insert into the collective list */
+ entry_ptr->coll_access = TRUE;
+ H5C__INSERT_IN_COLL_LIST(cache_ptr, entry_ptr, NULL)
+ } /* end if */
+ else if(entry_ptr->coll_access) {
+ H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL)
+ } /* end else-if */
} /* end if */
- else if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && coll_access && entry_ptr->coll_access) {
- H5C__MOVE_TO_TOP_IN_COLL_LIST(cache_ptr, entry_ptr, NULL)
- } /* end else-if */
#endif /* H5_HAVE_PARALLEL */
#if H5C_DO_TAGGING_SANITY_CHECKS
@@ -3057,16 +3060,16 @@ H5C_protect(H5F_t * f,
#ifdef H5_HAVE_PARALLEL
if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) {
/* Make sure the size of the collective entries in the cache remain in check */
- if(TRUE == coll_access) {
+ if(coll_access) {
if(H5P_USER_TRUE == f->coll_md_read) {
if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100)
- if(H5C_clear_coll_entries(cache_ptr, 1) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "H5C_clear_coll_entries() failed.")
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries")
} /* end if */
else {
if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100)
- if(H5C_clear_coll_entries(cache_ptr, 1) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "H5C_clear_coll_entries() failed.")
+ if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries")
} /* end else */
} /* end if */
} /* end if */
@@ -7707,7 +7710,11 @@ done:
*/
herr_t
H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ptr,
- unsigned flags, int64_t *entry_size_change_ptr, H5SL_t *collective_write_list)
+ unsigned flags, int64_t *entry_size_change_ptr, H5SL_t
+#ifndef H5_HAVE_PARALLEL
+ H5_ATTR_UNUSED
+#endif /* NDEBUG */
+ *collective_write_list)
{
H5C_t * cache_ptr; /* Cache for file */
hbool_t destroy; /* external flag */
@@ -7718,11 +7725,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_
hbool_t write_entry; /* internal flag */
hbool_t destroy_entry; /* internal flag */
hbool_t was_dirty;
- haddr_t new_addr = HADDR_UNDEF;
- haddr_t old_addr = HADDR_UNDEF;
haddr_t entry_addr = HADDR_UNDEF;
- size_t new_len = 0;
- size_t new_compressed_len = 0;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -7807,7 +7810,6 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_
/* serialize the entry if necessary, and then write it to disk. */
if(write_entry) {
- unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET;
/* The entry is dirty, and we are doing either a flush,
* or a flush destroy. In either case, serialize the
@@ -7847,225 +7849,9 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_
} /* end if */
if(!(entry_ptr->image_up_to_date)) {
- /* reset cache_ptr->slist_changed so we can detect slist
- * modifications in the pre_serialize call.
- */
- cache_ptr->slist_changed = FALSE;
-
- /* make note of the entry's current address */
- old_addr = entry_ptr->addr;
-
- /* Call client's pre-serialize callback, if there's one */
- if ( ( entry_ptr->type->pre_serialize != NULL ) &&
- ( (entry_ptr->type->pre_serialize)(f, dxpl_id,
- (void *)entry_ptr,
- entry_ptr->addr,
- entry_ptr->size,
- entry_ptr->compressed_size,
- &new_addr, &new_len,
- &new_compressed_len,
- &serialize_flags) < 0 ) )
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry")
-
- /* set cache_ptr->slist_change_in_pre_serialize if the
- * slist was modified.
- */
- if(cache_ptr->slist_changed)
- cache_ptr->slist_change_in_pre_serialize = TRUE;
-
- /* Check for any flags set in the pre-serialize callback */
- if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) {
- /* Check for unexpected flags from serialize callback */
- if(serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG |
- H5C__SERIALIZE_MOVED_FLAG |
- H5C__SERIALIZE_COMPRESSED_FLAG))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)")
-#ifdef H5_HAVE_PARALLEL
- /* In the parallel case, resizes and moves in
- * the serialize operation can cause problems.
- * If they occur, scream and die.
- *
- * At present, in the parallel case, the aux_ptr
- * will only be set if there is more than one
- * process. Thus we can use this to detect
- * the parallel case.
- *
- * This works for now, but if we start using the
- * aux_ptr for other purposes, we will have to
- * change this test accordingly.
- *
- * NB: While this test detects entryies that attempt
- * to resize or move themselves during a flush
- * in the parallel case, it will not detect an
- * entry that dirties, resizes, and/or moves
- * other entries during its flush.
- *
- * From what Quincey tells me, this test is
- * sufficient for now, as any flush routine that
- * does the latter will also do the former.
- *
- * If that ceases to be the case, further
- * tests will be necessary.
- */
- if(cache_ptr->aux_ptr != NULL)
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occured in parallel case.")
-#endif /* H5_HAVE_PARALLEL */
-
- /* Resize the buffer if required */
- if ( ( ( ! entry_ptr->compressed ) &&
- ( serialize_flags & H5C__SERIALIZE_RESIZED_FLAG ) ) ||
- ( ( entry_ptr->compressed ) &&
- ( serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG ) ) )
- {
- size_t new_image_size;
-
- if(entry_ptr->compressed)
- new_image_size = new_compressed_len;
- else
- new_image_size = new_len;
- HDassert(new_image_size > 0);
-
- /* Release the current image */
- if(entry_ptr->image_ptr)
- entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr);
-
- /* Allocate a new image buffer */
- if(NULL == (entry_ptr->image_ptr = H5MM_malloc(new_image_size + H5C_IMAGE_EXTRA_SPACE)))
- HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
-#if H5C_DO_MEMORY_SANITY_CHECKS
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + new_image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
-#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
- } /* end if */
-
- /* If required, update the entry and the cache data structures
- * for a resize.
- */
- if(serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) {
- H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, \
- entry_ptr, new_len)
-
- /* update the hash table for the size change*/
- H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, \
- entry_ptr->size, \
- new_len, entry_ptr, \
- !(entry_ptr->is_dirty));
-
- /* The entry can't be protected since we are
- * in the process of flushing it. Thus we must
- * update the replacement policy data
- * structures for the size change. The macro
- * deals with the pinned case.
- */
- H5C__UPDATE_RP_FOR_SIZE_CHANGE(cache_ptr, entry_ptr, new_len);
-
- /* as we haven't updated the cache data structures for
- * for the flush or flush destroy yet, the entry should
- * be in the slist. Thus update it for the size change.
- */
- HDassert(entry_ptr->in_slist);
- H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \
- new_len)
-
- /* if defined, update *entry_size_change_ptr for the
- * change in entry size.
- */
- if(entry_size_change_ptr != NULL)
- *entry_size_change_ptr = (int64_t)new_len - (int64_t)(entry_ptr->size);
-
- /* finally, update the entry for its new size */
- entry_ptr->size = new_len;
- } /* end if */
-
- /* If required, udate the entry and the cache data structures
- * for a move
- */
- if(serialize_flags & H5C__SERIALIZE_MOVED_FLAG) {
-#if H5C_DO_SANITY_CHECKS
- int64_t saved_slist_len_increase;
- int64_t saved_slist_size_increase;
-#endif /* H5C_DO_SANITY_CHECKS */
-
- H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr)
-
- if(entry_ptr->addr == old_addr) {
- /* we must update cache data structures for the
- * change in address.
- */
-
- /* delete the entry from the hash table and the slist */
- H5C__DELETE_FROM_INDEX(cache_ptr, entry_ptr)
- H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr)
-
- /* update the entry for its new address */
- entry_ptr->addr = new_addr;
-
- /* and then reinsert in the index and slist */
- H5C__INSERT_IN_INDEX(cache_ptr, entry_ptr, FAIL)
-
-#if H5C_DO_SANITY_CHECKS
- /* save cache_ptr->slist_len_increase and
- * cache_ptr->slist_size_increase before the
- * reinsertion into the slist, and restore
- * them afterwards to avoid skewing our sanity
- * checking.
- */
- saved_slist_len_increase = cache_ptr->slist_len_increase;
- saved_slist_size_increase = cache_ptr->slist_size_increase;
-#endif /* H5C_DO_SANITY_CHECKS */
-
- H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL)
-
-#if H5C_DO_SANITY_CHECKS
- cache_ptr->slist_len_increase = saved_slist_len_increase;
- cache_ptr->slist_size_increase = saved_slist_size_increase;
-#endif /* H5C_DO_SANITY_CHECKS */
- }
- else /* move is alread done for us -- just do sanity checks */
- HDassert(entry_ptr->addr == new_addr);
- } /* end if */
-
- if(serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG) {
- /* just save the new compressed entry size in
- * entry_ptr->compressed_size. We don't need to
- * do more, as compressed size is only used for I/O.
- */
- HDassert(entry_ptr->compressed);
- entry_ptr->compressed_size = new_compressed_len;
- }
- } /* end if ( serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET ) */
-
- /* Serialize object into buffer */
- {
- size_t image_len;
-
- if(entry_ptr->compressed)
- image_len = entry_ptr->compressed_size;
- else
- image_len = entry_ptr->size;
-
- /* reset cache_ptr->slist_changed so we can detect slist
- * modifications in the serialize call.
- */
- cache_ptr->slist_changed = FALSE;
-
-
- if(entry_ptr->type->serialize(f, entry_ptr->image_ptr,
- image_len, (void *)entry_ptr) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry")
-
- /* set cache_ptr->slist_change_in_serialize if the
- * slist was modified.
- */
- if(cache_ptr->slist_changed)
- cache_ptr->slist_change_in_pre_serialize = TRUE;
-
-#if H5C_DO_MEMORY_SANITY_CHECKS
- HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + image_len,
- H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE));
-#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
-
- entry_ptr->image_up_to_date = TRUE;
- }
+ /* Generate the entry's image */
+ if(H5C__generate_image(f, cache_ptr, entry_ptr, dxpl_id, entry_size_change_ptr) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't generate entry's image")
} /* end if ( ! (entry_ptr->image_up_to_date) ) */
/* Finally, write the image to disk.
@@ -8091,10 +7877,10 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_
#ifdef H5_HAVE_PARALLEL
if(collective_write_list) {
- H5C_collective_write_t *item = NULL;
+ H5C_collective_write_t *item;
- if(NULL == (item = (H5C_collective_write_t *)H5MM_malloc(sizeof(H5C_collective_write_t))))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate skip list item")
+ if(NULL == (item = (H5C_collective_write_t *)H5FL_MALLOC(H5C_collective_write_t)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "unable to allocate skip list item")
item->length = image_size;
item->free_buf = FALSE;
@@ -8103,7 +7889,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_
if(H5SL_insert(collective_write_list, item, &item->offset) < 0) {
H5MM_free(item);
- HGOTO_ERROR(H5E_HEAP, H5E_CANTINSERT, FAIL, "unable to insert skip list item")
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTINSERT, FAIL, "unable to insert skip list item")
} /* end if */
} /* end if */
else
@@ -8778,7 +8564,6 @@ H5C_load_entry(H5F_t * f,
entry->clear_on_unprotect = FALSE;
entry->flush_immediately = FALSE;
entry->coll_access = coll_access;
- entry->ind_access_while_coll = FALSE;
#endif /* H5_HAVE_PARALLEL */
entry->flush_in_progress = FALSE;
entry->destroy_in_progress = FALSE;
@@ -8799,8 +8584,10 @@ H5C_load_entry(H5F_t * f,
entry->aux_next = NULL;
entry->aux_prev = NULL;
+#ifdef H5_HAVE_PARALLEL
entry->coll_next = NULL;
entry->coll_prev = NULL;
+#endif /* H5_HAVE_PARALLEL */
H5C__RESET_CACHE_ENTRY_STATS(entry);
@@ -9018,13 +8805,6 @@ H5C_make_space_in_cache(H5F_t * f,
cache_ptr->entries_scanned_to_make_space++;
#endif /* H5C_COLLECT_CACHE_STATS */
-#ifdef H5_HAVE_PARALLEL
- if(TRUE == entry_ptr->coll_access) {
- entry_ptr->coll_access = FALSE;
- H5C__REMOVE_FROM_COLL_LIST(cache_ptr, entry_ptr, FAIL)
- } /* end if */
-#endif
-
if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL, NULL) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry")
} else {
@@ -10207,9 +9987,22 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_get_entry_ring() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5C__generate_image
+ *
+ * Purpose: Serialize an entry and generate its image.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * 2/10/16
+ *
+ *-------------------------------------------------------------------------
+ */
static herr_t
-H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
- hid_t dxpl_id, int64_t *entry_size_change_ptr)
+H5C__generate_image(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t *entry_ptr,
+ hid_t dxpl_id, int64_t *entry_size_change_ptr)
{
haddr_t new_addr = HADDR_UNDEF;
haddr_t old_addr = HADDR_UNDEF;
@@ -10218,8 +10011,9 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
unsigned serialize_flags = H5C__SERIALIZE_NO_FLAGS_SET;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
+ /* Sanity check */
HDassert(!entry_ptr->image_up_to_date);
/* reset cache_ptr->slist_changed so we can detect slist
@@ -10231,93 +10025,91 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
old_addr = entry_ptr->addr;
/* Call client's pre-serialize callback, if there's one */
- if ( ( entry_ptr->type->pre_serialize != NULL ) &&
- ( (entry_ptr->type->pre_serialize)(f, dxpl_id,
- (void *)entry_ptr,
- entry_ptr->addr,
- entry_ptr->size,
- entry_ptr->compressed_size,
- &new_addr, &new_len,
- &new_compressed_len,
- &serialize_flags) < 0 ) ) {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "unable to pre-serialize entry");
- }
+ if(entry_ptr->type->pre_serialize &&
+ (entry_ptr->type->pre_serialize)(f, dxpl_id,
+ (void *)entry_ptr, entry_ptr->addr, entry_ptr->size,
+ entry_ptr->compressed_size, &new_addr, &new_len,
+ &new_compressed_len, &serialize_flags) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to pre-serialize entry")
/* set cache_ptr->slist_change_in_pre_serialize if the
* slist was modified.
*/
- if ( cache_ptr->slist_changed )
+ if(cache_ptr->slist_changed)
cache_ptr->slist_change_in_pre_serialize = TRUE;
/* Check for any flags set in the pre-serialize callback */
- if ( serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET ) {
+ if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) {
/* Check for unexpected flags from serialize callback */
- if ( serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG |
- H5C__SERIALIZE_MOVED_FLAG |
- H5C__SERIALIZE_COMPRESSED_FLAG)) {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "unknown serialize flag(s)");
- }
+ if(serialize_flags & ~(H5C__SERIALIZE_RESIZED_FLAG |
+ H5C__SERIALIZE_MOVED_FLAG |
+ H5C__SERIALIZE_COMPRESSED_FLAG))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unknown serialize flag(s)")
#ifdef H5_HAVE_PARALLEL
- if ( cache_ptr->aux_ptr != NULL )
- HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \
- "resize/move in serialize occured in parallel case.");
+ /* In the parallel case, resizes and moves in
+ * the serialize operation can cause problems.
+ * If they occur, scream and die.
+ *
+ * At present, in the parallel case, the aux_ptr
+ * will only be set if there is more than one
+ * process. Thus we can use this to detect
+ * the parallel case.
+ *
+ * This works for now, but if we start using the
+ * aux_ptr for other purposes, we will have to
+ * change this test accordingly.
+ *
+ * NB: While this test detects entryies that attempt
+ * to resize or move themselves during a flush
+ * in the parallel case, it will not detect an
+ * entry that dirties, resizes, and/or moves
+ * other entries during its flush.
+ *
+ * From what Quincey tells me, this test is
+ * sufficient for now, as any flush routine that
+ * does the latter will also do the former.
+ *
+ * If that ceases to be the case, further
+ * tests will be necessary.
+ */
+ if(cache_ptr->aux_ptr != NULL)
+ HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "resize/move in serialize occured in parallel case.")
#endif
/* Resize the buffer if required */
- if ( ( ( ! entry_ptr->compressed ) &&
- ( serialize_flags & H5C__SERIALIZE_RESIZED_FLAG ) ) ||
- ( ( entry_ptr->compressed ) &&
- ( serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG ) ) ) {
+ if(((!entry_ptr->compressed) && (serialize_flags & H5C__SERIALIZE_RESIZED_FLAG)) ||
+ ((entry_ptr->compressed) && (serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG))) {
size_t new_image_size;
- if ( entry_ptr->compressed )
+ if(entry_ptr->compressed)
new_image_size = new_compressed_len;
else
new_image_size = new_len;
-
HDassert(new_image_size > 0);
/* Release the current image */
- if ( entry_ptr->image_ptr ) {
+ if(entry_ptr->image_ptr)
entry_ptr->image_ptr = H5MM_xfree(entry_ptr->image_ptr);
- }
/* Allocate a new image buffer */
- entry_ptr->image_ptr =
- H5MM_malloc(new_image_size + H5C_IMAGE_EXTRA_SPACE);
-
- if ( NULL == entry_ptr->image_ptr )
- {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, \
- "memory allocation failed for on disk image buffer");
- }
+ if(NULL == (entry_ptr->image_ptr = H5MM_malloc(new_image_size + H5C_IMAGE_EXTRA_SPACE)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed for on disk image buffer")
#if H5C_DO_MEMORY_SANITY_CHECKS
-
- HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + new_image_size,
- H5C_IMAGE_SANITY_VALUE,
- H5C_IMAGE_EXTRA_SPACE);
-
+ HDmemcpy(((uint8_t *)entry_ptr->image_ptr) + new_image_size, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE);
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
-
} /* end if */
/* If required, update the entry and the cache data structures
* for a resize.
*/
- if ( serialize_flags & H5C__SERIALIZE_RESIZED_FLAG ) {
-
- H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, \
- entry_ptr, new_len);
+ if(serialize_flags & H5C__SERIALIZE_RESIZED_FLAG) {
+ H5C__UPDATE_STATS_FOR_ENTRY_SIZE_CHANGE(cache_ptr, entry_ptr, new_len);
/* update the hash table for the size change*/
- H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, \
- entry_ptr->size, \
- new_len, entry_ptr, \
- !(entry_ptr->is_dirty));
+ H5C__UPDATE_INDEX_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \
+ new_len, entry_ptr, !(entry_ptr->is_dirty));
/* The entry can't be protected since we are
* in the process of flushing it. Thus we must
@@ -10332,17 +10124,13 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
* be in the slist. Thus update it for the size change.
*/
HDassert(entry_ptr->in_slist);
- H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, \
- new_len);
+ H5C__UPDATE_SLIST_FOR_SIZE_CHANGE(cache_ptr, entry_ptr->size, new_len);
/* if defined, update *entry_size_change_ptr for the
* change in entry size.
*/
- if ( entry_size_change_ptr != NULL )
- {
- *entry_size_change_ptr = (int64_t)new_len;
- *entry_size_change_ptr -= (int64_t)(entry_ptr->size);
- }
+ if(entry_size_change_ptr != NULL)
+ *entry_size_change_ptr = (int64_t)new_len - (int64_t)(entry_ptr->size);
/* finally, update the entry for its new size */
entry_ptr->size = new_len;
@@ -10359,7 +10147,7 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
H5C__UPDATE_STATS_FOR_MOVE(cache_ptr, entry_ptr);
- if ( entry_ptr->addr == old_addr ) {
+ if(entry_ptr->addr == old_addr) {
/* we must update cache data structures for the
* change in address.
*/
@@ -10391,27 +10179,26 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
cache_ptr->slist_len_increase = saved_slist_len_increase;
cache_ptr->slist_size_increase = saved_slist_size_increase;
#endif /* H5C_DO_SANITY_CHECKS */
- }
- else {
+ } /* end if */
+ else /* move is already done for us -- just do sanity checks */
HDassert(entry_ptr->addr == new_addr);
- }
} /* end if */
- if ( serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG ) {
+ if(serialize_flags & H5C__SERIALIZE_COMPRESSED_FLAG) {
/* just save the new compressed entry size in
* entry_ptr->compressed_size. We don't need to
* do more, as compressed size is only used for I/O.
*/
HDassert(entry_ptr->compressed);
entry_ptr->compressed_size = new_compressed_len;
- }
- } /* end if ( serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET ) */
+ } /* end if */
+ } /* end if(serialize_flags != H5C__SERIALIZE_NO_FLAGS_SET) */
/* Serialize object into buffer */
{
size_t image_len;
- if ( entry_ptr->compressed )
+ if(entry_ptr->compressed)
image_len = entry_ptr->compressed_size;
else
image_len = entry_ptr->size;
@@ -10420,33 +10207,25 @@ H5C__generate_image(H5F_t *f, H5C_t * cache_ptr, H5C_cache_entry_t *entry_ptr,
* modifications in the serialize call.
*/
cache_ptr->slist_changed = FALSE;
-
- if ( entry_ptr->type->serialize(f, entry_ptr->image_ptr,
- image_len,
- (void *)entry_ptr) < 0) {
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, \
- "unable to serialize entry");
- }
+ if(entry_ptr->type->serialize(f, entry_ptr->image_ptr, image_len, (void *)entry_ptr) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to serialize entry")
/* set cache_ptr->slist_change_in_serialize if the
* slist was modified.
*/
- if ( cache_ptr->slist_changed )
+ if(cache_ptr->slist_changed)
cache_ptr->slist_change_in_pre_serialize = TRUE;
#if H5C_DO_MEMORY_SANITY_CHECKS
-
- HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) +
- image_len,
- H5C_IMAGE_SANITY_VALUE,
- H5C_IMAGE_EXTRA_SPACE));
-
+ HDassert(0 == HDmemcmp(((uint8_t *)entry_ptr->image_ptr) + image_len,
+ H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE));
#endif /* H5C_DO_MEMORY_SANITY_CHECKS */
entry_ptr->image_up_to_date = TRUE;
- }
+ } /* end block */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5C__generate_image */
+