From 560e80c0ad8494a2e070aafde9cbcff11de99219 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 23 Feb 2024 11:06:06 -0600 Subject: Improve performance of flushing single objects (#4017) Improve performance of flushing a single object, and remove metadata cache flush markers --- src/H5AC.c | 4 +- src/H5ACprivate.h | 2 - src/H5C.c | 79 +- src/H5Centry.c | 58 +- src/H5Cint.c | 36 +- src/H5Cpkg.h | 9 +- src/H5Cprivate.h | 48 +- src/H5Ctag.c | 148 +- test/cache.c | 6477 +++++++++++++++++++------------------------------- test/cache_common.h | 12 +- test/cache_tagging.c | 11 +- 11 files changed, 2627 insertions(+), 4257 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 802ccdd..b752803 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -459,7 +459,7 @@ H5AC_dest(H5F_t *f) */ if (H5F_ACC_RDWR & H5F_INTENT(f)) { /* enable and load the skip list */ - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + if (H5C_set_slist_enabled(f->shared->cache, true, true) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't enable skip list"); if (H5AC__flush_entries(f) < 0) @@ -1127,7 +1127,7 @@ H5AC_prep_for_file_flush(H5F_t *f) assert(f->shared); assert(f->shared->cache); - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + if (H5C_set_slist_enabled(f->shared->cache, true, true) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't enable skip list"); done: diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 5e23036..51f1b35 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -312,14 +312,12 @@ typedef struct H5AC_proxy_entry_t { */ #define H5AC__NO_FLAGS_SET H5C__NO_FLAGS_SET -#define H5AC__SET_FLUSH_MARKER_FLAG H5C__SET_FLUSH_MARKER_FLAG #define H5AC__DELETED_FLAG H5C__DELETED_FLAG #define H5AC__DIRTIED_FLAG H5C__DIRTIED_FLAG #define H5AC__PIN_ENTRY_FLAG H5C__PIN_ENTRY_FLAG #define H5AC__UNPIN_ENTRY_FLAG H5C__UNPIN_ENTRY_FLAG #define H5AC__FLUSH_INVALIDATE_FLAG H5C__FLUSH_INVALIDATE_FLAG #define H5AC__FLUSH_CLEAR_ONLY_FLAG H5C__FLUSH_CLEAR_ONLY_FLAG -#define H5AC__FLUSH_MARKED_ENTRIES_FLAG H5C__FLUSH_MARKED_ENTRIES_FLAG #define H5AC__FLUSH_IGNORE_PROTECTED_FLAG H5C__FLUSH_IGNORE_PROTECTED_FLAG #define H5AC__READ_ONLY_FLAG H5C__READ_ONLY_FLAG #define H5AC__FREE_FILE_SPACE_FLAG H5C__FREE_FILE_SPACE_FLAG diff --git a/src/H5C.c b/src/H5C.c index eb6e49e..1713e83 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -493,7 +493,7 @@ H5C_dest(H5F_t *f) #endif /* H5AC_DUMP_IMAGE_STATS_ON_CLOSE */ /* Enable the slist, as it is needed in the flush */ - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + if (H5C_set_slist_enabled(f->shared->cache, true, true) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed"); /* Flush and invalidate all cache entries */ @@ -567,7 +567,7 @@ H5C_evict(H5F_t *f) assert(f); /* Enable the slist, as it is needed in the flush */ - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + if (H5C_set_slist_enabled(f->shared->cache, true, true) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed"); /* Flush and invalidate all cache entries except the pinned entries */ @@ -575,7 +575,7 @@ H5C_evict(H5F_t *f) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict entries in the cache"); /* Disable the slist */ - if (H5C_set_slist_enabled(f->shared->cache, false, true) < 0) + if (H5C_set_slist_enabled(f->shared->cache, false, false) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist disabled failed"); done: @@ -1042,41 +1042,32 @@ done: * * 1) Verifies that the slist is empty. * - * 2) Scans the index list, and inserts all dirty entries - * into the slist. + * 2) If the populate_slist parameter is true, scans the + * index list, and inserts all dirty entries into the + * slist. * * 3) Sets cache_ptr->slist_enabled = true. * - * Note that the clear_slist parameter is ignored if - * the slist_enabed parameter is true. - * * * If the slist_enabled_parameter is false, the function - * shuts down the slist. - * - * Normally the slist will be empty at this point, however - * that need not be the case if H5C_flush_cache() has been - * called with the H5C__FLUSH_MARKED_ENTRIES_FLAG. - * - * Thus shutdown proceeds as follows: + * shuts down the slist: * * 1) Test to see if the slist is empty. If it is, proceed * to step 3. * - * 2) Test to see if the clear_slist parameter is true. - * - * If it is, remove all entries from the slist. - * - * If it isn't, throw an error. + * 2) Remove all entries from the slist. * * 3) set cache_ptr->slist_enabled = false. * + * Note that the populate_slist parameter is ignored if + * the slist_enabed parameter is false. + * * Return: SUCCEED on success, and FAIL on failure. * *------------------------------------------------------------------------- */ herr_t -H5C_set_slist_enabled(H5C_t *cache_ptr, bool slist_enabled, bool clear_slist) +H5C_set_slist_enabled(H5C_t *cache_ptr, bool slist_enabled, bool populate_slist) { H5C_cache_entry_t *entry_ptr; herr_t ret_value = SUCCEED; /* Return value */ @@ -1097,40 +1088,30 @@ H5C_set_slist_enabled(H5C_t *cache_ptr, bool slist_enabled, bool clear_slist) */ cache_ptr->slist_enabled = true; - /* scan the index list and insert all dirty entries in the slist */ - entry_ptr = cache_ptr->il_head; - while (entry_ptr != NULL) { - if (entry_ptr->is_dirty) - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); - entry_ptr = entry_ptr->il_next; - } + if (populate_slist) { + /* scan the index list and insert all dirty entries in the slist */ + entry_ptr = cache_ptr->il_head; + while (entry_ptr != NULL) { + if (entry_ptr->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); + entry_ptr = entry_ptr->il_next; + } - /* we don't maintain a dirty index len, so we can't do a cross - * check against it. Note that there is no point in cross checking - * against the dirty LRU size, as the dirty LRU may not be maintained, - * and in any case, there is no requirement that all dirty entries - * will reside on the dirty LRU. - */ - assert(cache_ptr->dirty_index_size == cache_ptr->slist_size); + /* we don't maintain a dirty index len, so we can't do a cross + * check against it. Note that there is no point in cross checking + * against the dirty LRU size, as the dirty LRU may not be maintained, + * and in any case, there is no requirement that all dirty entries + * will reside on the dirty LRU. + */ + assert(cache_ptr->dirty_index_size == cache_ptr->slist_size); + } } else { /* take down the skip list */ if (!cache_ptr->slist_enabled) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist already disabled?"); - if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) { - if (clear_slist) { - H5SL_node_t *node_ptr; - - node_ptr = H5SL_first(cache_ptr->slist_ptr); - while (node_ptr != NULL) { - entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - H5C__REMOVE_ENTRY_FROM_SLIST(cache_ptr, entry_ptr, false, FAIL); - node_ptr = H5SL_first(cache_ptr->slist_ptr); - } - } - else - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?"); - } + if ((cache_ptr->slist_len != 0) || (cache_ptr->slist_size != 0)) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "slist not empty?"); cache_ptr->slist_enabled = false; diff --git a/src/H5Centry.c b/src/H5Centry.c index 2bbf9ac..fec1f4a 100644 --- a/src/H5Centry.c +++ b/src/H5Centry.c @@ -503,36 +503,24 @@ H5C__flush_single_entry(H5F_t *f, H5C_cache_entry_t *entry_ptr, unsigned flags) if (cache_ptr->slist_enabled) { if (entry_ptr->in_slist) { assert(entry_ptr->is_dirty); - if (entry_ptr->flush_marker && !entry_ptr->is_dirty) + if (!entry_ptr->is_dirty) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry in slist failed sanity checks"); } /* end if */ - else { - assert(!entry_ptr->is_dirty); - assert(!entry_ptr->flush_marker); - if (entry_ptr->is_dirty || entry_ptr->flush_marker) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "entry failed sanity checks"); - } /* end else */ } - else { /* slist is disabled */ + else /* slist is disabled */ assert(!entry_ptr->in_slist); - if (!entry_ptr->is_dirty) - if (entry_ptr->flush_marker) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "flush marked clean entry?"); - } #endif /* H5C_DO_SANITY_CHECKS */ if (entry_ptr->is_protected) /* Attempt to flush a protected entry -- scream and die. */ HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "Attempt to flush a protected entry"); - /* Set entry_ptr->flush_in_progress = true and set - * entry_ptr->flush_marker = false + /* Set entry_ptr->flush_in_progress = true * * We will set flush_in_progress back to false at the end if the * entry still exists at that point. */ entry_ptr->flush_in_progress = true; - entry_ptr->flush_marker = false; /* Preserve current dirty state for later */ was_dirty = entry_ptr->is_dirty; @@ -1240,7 +1228,6 @@ H5C__load_entry(H5F_t *f, entry->ro_ref_count = 0; entry->is_pinned = false; entry->in_slist = false; - entry->flush_marker = false; #ifdef H5_HAVE_PARALLEL entry->clear_on_unprotect = false; entry->flush_immediately = false; @@ -1897,7 +1884,6 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t 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; @@ -2095,7 +2081,6 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u #ifdef H5_HAVE_PARALLEL bool coll_access = false; /* whether access to the cache entry is done collectively */ #endif /* H5_HAVE_PARALLEL */ - bool set_flush_marker; bool write_permitted = true; size_t empty_space; H5C_cache_entry_t *entry_ptr = NULL; @@ -2125,9 +2110,8 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); + insert_pinned = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + flush_last = ((flags & H5C__FLUSH_LAST_FLAG) != 0); /* Get the ring type from the API context */ ring = H5CX_get_ring(); @@ -2301,7 +2285,6 @@ H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, u /* New entries are presumed to be dirty */ assert(entry_ptr->is_dirty); - entry_ptr->flush_marker = set_flush_marker; H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); H5C__UPDATE_RP_FOR_INSERTION(cache_ptr, entry_ptr, FAIL); @@ -2497,9 +2480,6 @@ H5C_mark_entry_clean(void *_thing) /* Mark the entry as clean if it isn't already */ entry_ptr->is_dirty = false; - /* Also reset the 'flush_marker' flag, since the entry shouldn't be flushed now */ - entry_ptr->flush_marker = false; - /* Modify cache data structures */ if (was_dirty) H5C__UPDATE_INDEX_FOR_ENTRY_CLEAN(cache_ptr, entry_ptr, FAIL); @@ -3426,7 +3406,6 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) H5C_t *cache_ptr; bool deleted; bool dirtied; - bool set_flush_marker; bool pin_entry; bool unpin_entry; bool free_file_space; @@ -3441,13 +3420,12 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) FUNC_ENTER_NOAPI(FAIL) - deleted = ((flags & H5C__DELETED_FLAG) != 0); - dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); - set_flush_marker = ((flags & H5C__SET_FLUSH_MARKER_FLAG) != 0); - pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); - unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); - free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); - take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); + deleted = ((flags & H5C__DELETED_FLAG) != 0); + dirtied = ((flags & H5C__DIRTIED_FLAG) != 0); + pin_entry = ((flags & H5C__PIN_ENTRY_FLAG) != 0); + unpin_entry = ((flags & H5C__UNPIN_ENTRY_FLAG) != 0); + free_file_space = ((flags & H5C__FREE_FILE_SPACE_FLAG) != 0); + take_ownership = ((flags & H5C__TAKE_OWNERSHIP_FLAG) != 0); assert(f); assert(f->shared); @@ -3621,15 +3599,10 @@ H5C_unprotect(H5F_t *f, haddr_t addr, void *thing, unsigned flags) entry_ptr->is_protected = false; - /* if the entry is dirty, 'or' its flush_marker with the set flush flag, - * and then add it to the skip list if it isn't there already. - */ - if (entry_ptr->is_dirty) { - entry_ptr->flush_marker |= set_flush_marker; - if (!entry_ptr->in_slist) - /* this is a no-op if cache_ptr->slist_enabled is false */ - H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); - } /* end if */ + /* if the entry is dirty, add it to the skip list if it isn't there already. */ + if (entry_ptr->is_dirty && !entry_ptr->in_slist) + /* this is a no-op if cache_ptr->slist_enabled is false */ + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry_ptr, FAIL); /* This implementation of the "deleted" option is a bit inefficient, as * we re-insert the entry to be deleted into the replacement policy @@ -4141,7 +4114,6 @@ H5C_remove_entry(void *_entry) /* Additional internal cache consistency checks */ assert(!entry->in_slist); - assert(!entry->flush_marker); assert(!entry->flush_in_progress); /* Note that the algorithm below is (very) similar to the set of operations diff --git a/src/H5Cint.c b/src/H5Cint.c index 31a947a..2e79a0d 100644 --- a/src/H5Cint.c +++ b/src/H5Cint.c @@ -1207,10 +1207,10 @@ H5C__flush_invalidate_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) old_ring_pel_len = cur_ring_pel_len; while (cache_ptr->index_ring_len[ring] > 0) { - /* first, try to flush-destroy any dirty entries. Do this by + /* First, try to flush-destroy any dirty entries. Do this by * making a scan through the slist. Note that new dirty entries - * may be created by the flush call backs. Thus it is possible - * that the slist will not be empty after we finish the scan. + * may be created by the flush call back, thus we may need to + * restart the scan (see below). */ #ifdef H5C_DO_SANITY_CHECKS @@ -1573,7 +1573,6 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) { H5C_t *cache_ptr = f->shared->cache; bool flushed_entries_last_pass; - bool flush_marked_entries; bool ignore_protected; bool tried_to_flush_protected_entry = false; bool restart_slist_scan; @@ -1603,12 +1602,10 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ - ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); - flush_marked_entries = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); + ignore_protected = ((flags & H5C__FLUSH_IGNORE_PROTECTED_FLAG) != 0); - if (!flush_marked_entries) - for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) - assert(cache_ptr->slist_ring_len[i] == 0); + for (i = (int)H5C_RING_UNDEFINED; i < (int)ring; i++) + assert(cache_ptr->slist_ring_len[i] == 0); assert(cache_ptr->flush_in_progress); @@ -1712,9 +1709,7 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) */ assert(entry_ptr->in_slist); assert(entry_ptr->is_dirty); - - if (!flush_marked_entries || entry_ptr->flush_marker) - assert(entry_ptr->ring >= ring); + assert(entry_ptr->ring >= ring); /* Advance node pointer now, before we delete its target * from the slist. @@ -1727,19 +1722,14 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) assert(next_entry_ptr->is_dirty); assert(next_entry_ptr->in_slist); - - if (!flush_marked_entries || next_entry_ptr->flush_marker) - assert(next_entry_ptr->ring >= ring); - + assert(next_entry_ptr->ring >= ring); assert(entry_ptr != next_entry_ptr); } /* end if */ else next_entry_ptr = NULL; - if ((!flush_marked_entries || entry_ptr->flush_marker) && - ((!entry_ptr->flush_me_last) || - ((entry_ptr->flush_me_last) && ((cache_ptr->num_last_entries >= cache_ptr->slist_len) || - (flush_marked_entries && entry_ptr->flush_marker)))) && + if (((!entry_ptr->flush_me_last) || + ((entry_ptr->flush_me_last) && cache_ptr->num_last_entries >= cache_ptr->slist_len)) && ((entry_ptr->flush_dep_nchildren == 0) || (entry_ptr->flush_dep_ndirty_children == 0)) && (entry_ptr->ring == ring)) { @@ -1790,10 +1780,8 @@ H5C__flush_ring(H5F_t *f, H5C_ring_t ring, unsigned flags) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "cache has protected items"); #ifdef H5C_DO_SANITY_CHECKS - if (!flush_marked_entries) { - assert(cache_ptr->slist_ring_len[ring] == 0); - assert(cache_ptr->slist_ring_size[ring] == 0); - } /* end if */ + assert(cache_ptr->slist_ring_len[ring] == 0); + assert(cache_ptr->slist_ring_size[ring] == 0); #endif /* H5C_DO_SANITY_CHECKS */ done: diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 5417684..4408774 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -2168,15 +2168,14 @@ typedef struct H5C_tag_info_t { * insert all dirtly entries in the skip list, and enable operations * on skip list by setting above control flag to true. * + * In the case of a partial flush (i.e. flush tagged entries), we only + * add tagged entries to the skip list, thus avoiding unnecessary scans + * over the entire cache. + * * At the end of a complete flush, we verify that the skip list is empty, * and set the control flag back to false, so as to avoid skip list * maintenance overhead until the next flush or close. * - * In the case of a partial flush (i.e. flush marked entries), we remove - * all remaining entries from the skip list, and then set the control flag - * back to false -- again avoiding skip list maintenance overhead until - * the next flush or close. - * * slist_enabled: Boolean flag used to control operation of the skip * list. If this filed is false, operations on the slist are * no-ops, and the slist must be empty. If it is true, diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 3477e75..9f12312 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -134,7 +134,6 @@ * * * These flags apply to H5C_insert_entry(): - * H5C__SET_FLUSH_MARKER_FLAG * H5C__PIN_ENTRY_FLAG * H5C__FLUSH_LAST_FLAG ; super block only * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only @@ -145,7 +144,6 @@ * H5C__FLUSH_COLLECTIVELY_FLAG ; super block only * * These flags apply to H5C_unprotect(): - * H5C__SET_FLUSH_MARKER_FLAG * H5C__DELETED_FLAG * H5C__DIRTIED_FLAG * H5C__PIN_ENTRY_FLAG @@ -162,7 +160,6 @@ * These flags apply to H5C_flush_cache(): * H5C__FLUSH_INVALIDATE_FLAG * H5C__FLUSH_CLEAR_ONLY_FLAG - * H5C__FLUSH_MARKED_ENTRIES_FLAG * H5C__FLUSH_IGNORE_PROTECTED_FLAG (can't use this flag in combination * with H5C__FLUSH_INVALIDATE_FLAG) * H5C__DURING_FLUSH_FLAG @@ -170,32 +167,29 @@ * These flags apply to H5C_flush_single_entry(): * H5C__FLUSH_INVALIDATE_FLAG * H5C__FLUSH_CLEAR_ONLY_FLAG - * H5C__FLUSH_MARKED_ENTRIES_FLAG * H5C__TAKE_OWNERSHIP_FLAG * H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG * H5C__GENERATE_IMAGE_FLAG * H5C__UPDATE_PAGE_BUFFER_FLAG */ #define H5C__NO_FLAGS_SET 0x00000 -#define H5C__SET_FLUSH_MARKER_FLAG 0x00001 -#define H5C__DELETED_FLAG 0x00002 -#define H5C__DIRTIED_FLAG 0x00004 -#define H5C__PIN_ENTRY_FLAG 0x00008 -#define H5C__UNPIN_ENTRY_FLAG 0x00010 -#define H5C__FLUSH_INVALIDATE_FLAG 0x00020 -#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00040 -#define H5C__FLUSH_MARKED_ENTRIES_FLAG 0x00080 -#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00100 -#define H5C__READ_ONLY_FLAG 0x00200 -#define H5C__FREE_FILE_SPACE_FLAG 0x00400 -#define H5C__TAKE_OWNERSHIP_FLAG 0x00800 -#define H5C__FLUSH_LAST_FLAG 0x01000 -#define H5C__FLUSH_COLLECTIVELY_FLAG 0x02000 -#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x04000 -#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x08000 -#define H5C__DURING_FLUSH_FLAG 0x10000 /* Set when the entire cache is being flushed */ -#define H5C__GENERATE_IMAGE_FLAG 0x20000 /* Set during parallel I/O */ -#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x40000 /* Set during parallel I/O */ +#define H5C__DELETED_FLAG 0x00001 +#define H5C__DIRTIED_FLAG 0x00002 +#define H5C__PIN_ENTRY_FLAG 0x00004 +#define H5C__UNPIN_ENTRY_FLAG 0x00008 +#define H5C__FLUSH_INVALIDATE_FLAG 0x00010 +#define H5C__FLUSH_CLEAR_ONLY_FLAG 0x00020 +#define H5C__FLUSH_IGNORE_PROTECTED_FLAG 0x00040 +#define H5C__READ_ONLY_FLAG 0x00080 +#define H5C__FREE_FILE_SPACE_FLAG 0x00100 +#define H5C__TAKE_OWNERSHIP_FLAG 0x00200 +#define H5C__FLUSH_LAST_FLAG 0x00400 +#define H5C__FLUSH_COLLECTIVELY_FLAG 0x00800 +#define H5C__EVICT_ALLOW_LAST_PINS_FLAG 0x01000 +#define H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG 0x02000 +#define H5C__DURING_FLUSH_FLAG 0x04000 /* Set when the entire cache is being flushed */ +#define H5C__GENERATE_IMAGE_FLAG 0x08000 /* Set during parallel I/O */ +#define H5C__UPDATE_PAGE_BUFFER_FLAG 0x10000 /* Set during parallel I/O */ /* Debugging/sanity checking/statistics settings */ /* #define H5C_DO_SANITY_CHECKS */ @@ -1074,11 +1068,6 @@ typedef int H5C_ring_t; * As a general rule, entries are placed in the list when they are * marked dirty. * - * flush_marker: Boolean flag indicating that the entry is to be flushed - * the next time H5C_flush_cache() is called with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. The flag is reset when - * the entry is flushed for whatever reason. - * * flush_me_last: Boolean flag indicating that this entry should not be * flushed from the cache until all other entries without the * flush_me_last flag set have been flushed. @@ -1557,7 +1546,6 @@ typedef struct H5C_cache_entry_t { int ro_ref_count; bool is_pinned; bool in_slist; - bool flush_marker; bool flush_me_last; #ifdef H5_HAVE_PARALLEL bool clear_on_unprotect; @@ -2207,7 +2195,7 @@ H5_DLL herr_t H5C_resize_entry(void *thing, size_t new_size); H5_DLL herr_t H5C_set_cache_auto_resize_config(H5C_t *cache_ptr, H5C_auto_size_ctl_t *config_ptr); H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, bool evictions_enabled); -H5_DLL herr_t H5C_set_slist_enabled(H5C_t *cache_ptr, bool slist_enabled, bool clear_slist); +H5_DLL herr_t H5C_set_slist_enabled(H5C_t *cache_ptr, bool slist_enabled, bool populate_slist); H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix); H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, bool display_detailed_stats); H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); diff --git a/src/H5Ctag.c b/src/H5Ctag.c index a1a9f42..8da6c13 100644 --- a/src/H5Ctag.c +++ b/src/H5Ctag.c @@ -80,8 +80,6 @@ typedef struct { /* Local Prototypes */ /********************/ static herr_t H5C__iter_tagged_entries_real(H5C_t *cache, haddr_t tag, H5C_tag_iter_cb_t cb, void *cb_ctx); -static herr_t H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag); -static herr_t H5C__flush_marked_entries(H5F_t *f); /*********************/ /* Package Variables */ @@ -520,101 +518,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5C_evict_tagged_entries() */ -/*------------------------------------------------------------------------- - * Function: H5C__mark_tagged_entries_cb - * - * Purpose: Callback to set the flush marker on dirty entries in the cache - * - * Return: H5_ITER_CONT (can't fail) - * - *------------------------------------------------------------------------- - */ -static int -H5C__mark_tagged_entries_cb(H5C_cache_entry_t *entry, void H5_ATTR_UNUSED *_ctx) -{ - /* Function enter macro */ - FUNC_ENTER_PACKAGE_NOERR - - /* Sanity checks */ - assert(entry); - - /* We only want to set the flush marker on entries that - * actually need flushed (i.e., dirty ones) */ - if (entry->is_dirty) - entry->flush_marker = true; - - FUNC_LEAVE_NOAPI(H5_ITER_CONT) -} /* H5C__mark_tagged_entries_cb() */ - -/*------------------------------------------------------------------------- - * Function: H5C__mark_tagged_entries - * - * Purpose: Set the flush marker on dirty entries in the cache that have - * the specified tag, as well as all globally tagged entries. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__mark_tagged_entries(H5C_t *cache, haddr_t tag) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - /* Function enter macro */ - FUNC_ENTER_PACKAGE - - /* Sanity check */ - assert(cache); - - /* Iterate through hash table entries, marking those with specified tag, as - * well as any major global entries which should always be flushed - * when flushing based on tag value */ - if (H5C__iter_tagged_entries(cache, tag, true, H5C__mark_tagged_entries_cb, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__mark_tagged_entries() */ - -/*------------------------------------------------------------------------- - * Function: H5C__flush_marked_entries - * - * Purpose: Flushes all marked entries in the cache. - * - * Return: FAIL if error is detected, SUCCEED otherwise. - * - *------------------------------------------------------------------------- - */ -static herr_t -H5C__flush_marked_entries(H5F_t *f) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_PACKAGE - - /* Assertions */ - assert(f != NULL); - - /* Enable the slist, as it is needed in the flush */ - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed"); - - /* Flush all marked entries */ - if (H5C_flush_cache(f, H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache"); - - /* Disable the slist. Set the clear_slist parameter to true - * since we called H5C_flush_cache() with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. - */ - if (H5C_set_slist_enabled(f->shared->cache, false, true) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C__flush_marked_entries */ - #ifdef H5C_DO_TAGGING_SANITY_CHECKS /*------------------------------------------------------------------------- @@ -685,6 +588,36 @@ done: #endif /*------------------------------------------------------------------------- + * Function: H5C__flush_tagged_entries_cb + * + * Purpose: Callback to set the flush marker on dirty entries in the cache + * + * Return: H5_ITER_CONT (can't fail) + * + *------------------------------------------------------------------------- + */ +static int +H5C__flush_tagged_entries_cb(H5C_cache_entry_t *entry, void *_ctx) +{ + H5C_t *cache_ptr = (H5C_t *)_ctx; + int ret_value = H5_ITER_CONT; + + /* Function enter macro */ + FUNC_ENTER_PACKAGE + + /* Sanity checks */ + assert(entry); + assert(cache_ptr); + + /* We only want to add entries to the slist that actually need flushed (i.e., dirty ones) */ + if (entry->is_dirty) + H5C__INSERT_ENTRY_IN_SLIST(cache_ptr, entry, H5_ITER_ERROR); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__flush_tagged_entries_cb() */ + +/*------------------------------------------------------------------------- * Function: H5C_flush_tagged_entries * * Purpose: Flushes all entries with the specified tag to disk. @@ -709,13 +642,22 @@ H5C_flush_tagged_entries(H5F_t *f, haddr_t tag) /* Get cache pointer */ cache = f->shared->cache; - /* Mark all entries with specified tag */ - if (H5C__mark_tagged_entries(cache, tag) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't mark tagged entries"); + /* Enable the slist, as it is needed in the flush */ + if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "set slist enabled failed"); + + /* Iterate through hash table entries, adding those with specified tag to the slist, as well as any major + * global entries which should always be flushed when flushing based on tag value */ + if (H5C__iter_tagged_entries(cache, tag, true, H5C__flush_tagged_entries_cb, cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADITER, FAIL, "Iteration of tagged entries failed"); + + /* Flush all entries in the slist */ + if (H5C_flush_cache(f, H5C__FLUSH_IGNORE_PROTECTED_FLAG) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache"); - /* Flush all marked entries */ - if (H5C__flush_marked_entries(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush marked entries"); + /* Disable the slist */ + if (H5C_set_slist_enabled(f->shared->cache, false, false) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "disable slist failed"); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/test/cache.c b/test/cache.c index 4e62886..09d6a1f 100644 --- a/test/cache.c +++ b/test/cache.c @@ -2779,16 +2779,14 @@ check_insert_entry(unsigned paged) if (pass) { insert_entry(file_ptr, entry_type, 0, H5C__NO_FLAGS_SET); - insert_entry(file_ptr, entry_type, 1, H5C__SET_FLUSH_MARKER_FLAG); - insert_entry(file_ptr, entry_type, 2, H5C__PIN_ENTRY_FLAG); - insert_entry(file_ptr, entry_type, 3, (H5C__SET_FLUSH_MARKER_FLAG | H5C__PIN_ENTRY_FLAG)); + insert_entry(file_ptr, entry_type, 1, H5C__PIN_ENTRY_FLAG); } /* Verify that the entries are inserted as desired. */ i = 0; base_addr = entries[0]; - while (pass && (i < 4)) { + while (pass && (i < 2)) { entry_ptr = &(base_addr[i]); /* Start by checking everything we can via H5C_get_entry_status() */ @@ -2815,7 +2813,7 @@ check_insert_entry(unsigned paged) if (pass) { /* verify that the pinned flag got set correctly */ - if ((i == 2) || (i == 3)) { + if (i == 1) { if (!is_pinned) { @@ -2841,24 +2839,6 @@ check_insert_entry(unsigned paged) if (pass) { - /* Verify that the flush marker got set correctly */ - if ((i == 1) || (i == 3)) { - - if (!((entry_ptr->header).flush_marker)) { - - pass = false; - failure_mssg = "Unexpected insert results 5."; - } - } - else if ((entry_ptr->header).flush_marker) { - - pass = false; - failure_mssg = "Unexpected insert results 6."; - } - } - - if (pass) { - /* Verify that pinned entries are in the pinned entry list */ if ((entry_ptr->header).is_pinned) { @@ -2927,15 +2907,15 @@ check_insert_entry(unsigned paged) if (pass) { - if ((cache_ptr->index_len != 4) || (cache_ptr->index_size != 4 * entry_sizes[entry_type]) || + if ((cache_ptr->index_len != 2) || (cache_ptr->index_size != 2 * entry_sizes[entry_type]) || ((cache_ptr->slist_enabled) && - ((cache_ptr->slist_len != 4) || (cache_ptr->slist_size != 4 * entry_sizes[entry_type]))) || - (cache_ptr->pl_len != 0) || (cache_ptr->pl_size != (size_t)0) || (cache_ptr->pel_len != 2) || - (cache_ptr->pel_size != 2 * entry_sizes[entry_type]) || (cache_ptr->LRU_list_len != 2) || - (cache_ptr->LRU_list_size != 2 * entry_sizes[entry_type]) + ((cache_ptr->slist_len != 2) || (cache_ptr->slist_size != 2 * entry_sizes[entry_type]))) || + (cache_ptr->pl_len != 0) || (cache_ptr->pl_size != (size_t)0) || (cache_ptr->pel_len != 1) || + (cache_ptr->pel_size != 1 * entry_sizes[entry_type]) || (cache_ptr->LRU_list_len != 1) || + (cache_ptr->LRU_list_size != 1 * entry_sizes[entry_type]) #if H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS - || (cache_ptr->dLRU_list_len != 2) || - (cache_ptr->dLRU_list_size != 2 * entry_sizes[entry_type]) || (cache_ptr->cLRU_list_len != 0) || + || (cache_ptr->dLRU_list_len != 1) || + (cache_ptr->dLRU_list_size != 1 * entry_sizes[entry_type]) || (cache_ptr->cLRU_list_len != 0) || (cache_ptr->cLRU_list_size != (size_t)0) #endif /* H5C_MAINTAIN_CLEAN_AND_DIRTY_LRU_LISTS */ ) { @@ -2951,14 +2931,12 @@ check_insert_entry(unsigned paged) #if H5C_COLLECT_CACHE_STATS if (pass) { - if ((cache_ptr->insertions[entry_type] != 4) || (cache_ptr->pinned_insertions[entry_type] != 2) || - (cache_ptr->pins[entry_type] != 2) || (cache_ptr->unpins[entry_type] != 0) || - (cache_ptr->dirty_pins[entry_type] != 0) || (cache_ptr->max_index_len != 4) || - (cache_ptr->max_index_size != 4 * entry_sizes[entry_type]) || - ((cache_ptr->slist_enabled) && - ((cache_ptr->slist_len != 4) || (cache_ptr->slist_size != 4 * entry_sizes[entry_type]))) || - (cache_ptr->max_pl_len != 0) || (cache_ptr->max_pl_size != (size_t)0) || - (cache_ptr->max_pel_len != 2) || (cache_ptr->max_pel_size != 2 * entry_sizes[entry_type])) { + if ((cache_ptr->insertions[entry_type] != 2) || (cache_ptr->pinned_insertions[entry_type] != 1) || + (cache_ptr->pins[entry_type] != 1) || (cache_ptr->unpins[entry_type] != 0) || + (cache_ptr->dirty_pins[entry_type] != 0) || (cache_ptr->max_index_len != 2) || + (cache_ptr->max_index_size != 2 * entry_sizes[entry_type]) || (cache_ptr->max_pl_len != 0) || + (cache_ptr->max_pl_size != (size_t)0) || (cache_ptr->max_pel_len != 1) || + (cache_ptr->max_pel_size != 1 * entry_sizes[entry_type])) { pass = false; failure_mssg = "Unexpected insert results 11."; @@ -2970,8 +2948,7 @@ check_insert_entry(unsigned paged) if (pass) { - unpin_entry(entry_type, 2); - unpin_entry(entry_type, 3); + unpin_entry(entry_type, 1); } if (pass) { @@ -3130,12 +3107,6 @@ check_flush_cache__empty_cache(H5F_t *file_ptr) "flush with flags = 0x08 failed on empty cache.\n") } - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_MARKED_ENTRIES_FLAG, - "flush with flags = 0x10 failed on empty cache.\n") - } - } /* check_flush_cache__empty_cache() */ /*------------------------------------------------------------------------- @@ -3169,12 +3140,382 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) int test_num = 1; unsigned int flush_flags = H5C__NO_FLAGS_SET; unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { + struct flush_cache_test_spec spec[8] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 2; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 3; + unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + if (pass) { + int test_num = 4; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ true}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + /* verify that all other flags are ignored */ + if (pass) { + int test_num = 5; + unsigned int flush_flags = (unsigned)~(H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG); + unsigned int spec_size = 8; + struct flush_cache_test_spec spec[8] = {{/* entry_num = */ 0, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 1, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 75, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 2, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 25, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 3, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 50, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 4, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ true, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}, + {/* entry_num = */ 5, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 6, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 30, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}, + {/* entry_num = */ 7, + /* entry_type = */ MONSTER_ENTRY_TYPE, + /* entry_index = */ 40, + /* insert_flag = */ true, + /* flags = */ H5C__NO_FLAGS_SET, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}}; + + check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + } + + /* Now do pinned entry tests: + * + * For the most part, this test is directed at testing the ability + * of the flush routine to unravel collections of pinned entries. + */ + + if (pass) { + int test_num = 1; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { {/* entry_num = */ 0, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 100, /* insert_flag = */ false, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, /* expected_destroyed = */ false}, @@ -3183,6 +3524,9 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 75, /* insert_flag = */ false, /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ true, /* expected_destroyed = */ false}, @@ -3191,6 +3535,9 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 25, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ false}, @@ -3199,6 +3546,10 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 50, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ false}, @@ -3206,7 +3557,11 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 10, /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 4, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, /* expected_destroyed = */ false}, @@ -3214,7 +3569,12 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 20, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 5, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, + -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ true, /* expected_destroyed = */ false}, @@ -3222,7 +3582,12 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 30, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 6, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, + MONSTER_ENTRY_TYPE, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ false}, @@ -3230,24 +3595,32 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 40, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 7, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, + MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, 30, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ false}}; - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } if (pass) { - int test_num = 2; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { + int test_num = 2; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { {/* entry_num = */ 0, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 100, /* insert_flag = */ false, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, /* expected_destroyed = */ true}, @@ -3256,6 +3629,9 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 75, /* insert_flag = */ false, /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ true, /* expected_destroyed = */ true}, @@ -3264,6 +3640,9 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 25, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ true}, @@ -3272,6 +3651,10 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_index = */ 50, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ true}, @@ -3279,7 +3662,10 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 10, /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, /* expected_destroyed = */ true}, @@ -3287,7 +3673,10 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 20, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, -1, -1, -1, -1 - 1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, -1, -1, -1 - 1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ true, /* expected_destroyed = */ true}, @@ -3295,7 +3684,10 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 30, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 2, + /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, 20, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ true}, @@ -3303,1038 +3695,274 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 40, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 3, + /* pin_type[MAX_PINS] = */ + {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {10, 20, 30, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ true, /* expected_destroyed = */ true}}; - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } if (pass) { - int test_num = 3; - unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { + int test_num = 3; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; + unsigned int spec_size = 8; + struct pe_flush_cache_test_spec spec[8] = { {/* entry_num = */ 0, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 100, /* insert_flag = */ false, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 1, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 75, /* insert_flag = */ false, /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 2, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 25, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 3, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 50, /* insert_flag = */ true, /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 1, + /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 4, /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 10, /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 5, /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 20, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__DIRTIED_FLAG, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ true, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 6, /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 30, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ false, - /* expected_destroyed = */ false}, + /* expected_destroyed = */ true}, {/* entry_num = */ 7, /* entry_type = */ MONSTER_ENTRY_TYPE, /* entry_index = */ 40, /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, + /* num_pins = */ 0, + /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, + /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, /* expected_deserialized = */ false, /* expected_serialized = */ false, - /* expected_destroyed = */ false}}; + /* expected_destroyed = */ true}}; - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); } - if (pass) { - int test_num = 4; - unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}}; +} /* check_flush_cache__multi_entry() */ - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); +/*------------------------------------------------------------------------- + * Function: check_flush_cache__multi_entry_test() + * + * Purpose : Run a multi entry flush cache test. + * + * Return: void + * + *------------------------------------------------------------------------- + */ + +static void +check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, struct flush_cache_test_spec spec[]) +{ + H5C_t *cache_ptr = file_ptr->shared->cache; + static char msg[128]; + unsigned u; + size_t total_entry_size = 0; + test_entry_t *base_addr; + test_entry_t *entry_ptr; + + if (cache_ptr == NULL) { + + pass = false; + snprintf(msg, (size_t)128, "cache_ptr NULL on entry to single entry test #%d.", test_num); + failure_mssg = msg; } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - if (pass) { - int test_num = 5; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}}; + pass = false; - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + snprintf(msg, (size_t)128, "cache not empty at beginning of multi entry test #%d.", test_num); + failure_mssg = msg; } + else if ((spec_size < 1) || (spec == NULL)) { - if (pass) { - int test_num = 6; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}}; + pass = false; + snprintf(msg, (size_t)128, "missing/bad test spec on entry to multi entry test #%d.", test_num); + failure_mssg = msg; + } - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + u = 0; + while (pass && (u < spec_size)) { + + if (((unsigned)spec[u].entry_num != u) || (spec[u].entry_type < 0) || + (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[u].entry_index < 0) || + (spec[u].entry_index > max_indices[spec[u].entry_type])) { + + pass = false; + snprintf(msg, (size_t)128, "bad data in spec[%u] on entry to multi entry test #%d.", u, test_num); + failure_mssg = msg; + } + u++; } - if (pass) { - int test_num = 7; - unsigned int flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}}; + u = 0; + while (pass && (u < spec_size)) { - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + if (spec[u].insert_flag) { + + insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); + } + else { + + protect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index); + + unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); + } + + total_entry_size += entry_sizes[spec[u].entry_type]; + + u++; } if (pass) { - int test_num = 8; - unsigned int flush_flags = - H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}}; - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); - } + H5C_FLUSH_CACHE(file_ptr, flush_flags, "dummy failure message.\n") - /* verify that all other flags are ignored */ - if (pass) { - int test_num = 9; - unsigned int flush_flags = (unsigned)~(H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG); - unsigned int spec_size = 8; - struct flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}}; + if (!pass) { - check_flush_cache__multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + snprintf(msg, (size_t)128, "flush with flags 0x%x failed in multi entry test #%d.", flush_flags, + test_num); + failure_mssg = msg; + } } - /* Now do pinned entry tests: - * - * For the most part, this test is directed at testing the ability - * of the flush routine to unravel collections of pinned entries. - */ + u = 0; + while (pass && (u < spec_size)) { + base_addr = entries[spec[u].entry_type]; + entry_ptr = &(base_addr[spec[u].entry_index]); - if (pass) { - int test_num = 1; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 5, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, - -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 6, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 7, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, MONSTER_ENTRY_TYPE, - MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, 10, 20, 30, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}}; + if ((entry_ptr->deserialized != spec[u].expected_deserialized) || + (entry_ptr->serialized != spec[u].expected_serialized) || + (entry_ptr->destroyed != spec[u].expected_destroyed)) { - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + pass = false; + snprintf(msg, (size_t)128, "Bad status on entry %u after flush in multi entry test #%d.", u, + test_num); + failure_mssg = msg; + } + u++; } if (pass) { - int test_num = 2; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, -1, -1, -1, -1 - 1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, -1, -1, -1 - 1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 2, - /* pin_type[MAX_PINS] = */ {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, 20, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 3, - /* pin_type[MAX_PINS] = */ - {MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, MONSTER_ENTRY_TYPE, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {10, 20, 30, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}}; - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != spec_size) || (cache_ptr->index_size != total_entry_size))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { + + pass = false; + snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in multi entry test #%d.", + test_num); + failure_mssg = msg; + } } + /* clean up the cache to prep for the next test */ if (pass) { - int test_num = 3; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}}; - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, "dummy mssg.\n") + + if (!pass) { + + pass = false; + snprintf(msg, (size_t)128, "Flush failed on cleanup in multi entry test #%d.", test_num); + failure_mssg = msg; + } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { + + pass = false; + snprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in multi entry test #%d.", + test_num); + failure_mssg = msg; + } } - if (pass) { - int test_num = 4; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 4, - /* pin_type[MAX_PINS] = */ - {PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, PICO_ENTRY_TYPE, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, 75, 25, 50, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}}; + u = 0; + while (pass && (u < spec_size)) { - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); - } + base_addr = entries[spec[u].entry_type]; + entry_ptr = &(base_addr[spec[u].entry_index]); - if (pass) { - int test_num = 5; - unsigned int flush_flags = - H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | H5C__FLUSH_MARKED_ENTRIES_FLAG; - unsigned int spec_size = 8; - struct pe_flush_cache_test_spec spec[8] = { - {/* entry_num = */ 0, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 0, - /* pin_type[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {-1, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 1, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 75, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 25, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 50, - /* insert_flag = */ true, - /* flags = */ H5C__NO_FLAGS_SET, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 4, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 5, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 6, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 30, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}, - {/* entry_num = */ 7, - /* entry_type = */ MONSTER_ENTRY_TYPE, - /* entry_index = */ 40, - /* insert_flag = */ true, - /* flags = */ H5C__SET_FLUSH_MARKER_FLAG, - /* num_pins = */ 1, - /* pin_type[MAX_PINS] = */ {PICO_ENTRY_TYPE, -1, -1, -1, -1, -1, -1, -1}, - /* pin_idx[MAX_PINS] = */ {100, -1, -1, -1, -1, -1, -1, -1}, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ true}}; + entry_ptr->deserialized = false; + entry_ptr->serialized = false; + entry_ptr->destroyed = false; - check_flush_cache__pe_multi_entry_test(file_ptr, test_num, flush_flags, spec_size, spec); + u++; } -} /* check_flush_cache__multi_entry() */ +} /* check_flush_cache__multi_entry_test() */ /*------------------------------------------------------------------------- - * Function: check_flush_cache__multi_entry_test() * - * Purpose : Run a multi entry flush cache test. + * Function: check_flush_cache__pe_multi_entry_test() + * + * Purpose: Run a multi entry flush cache test. * * Return: void * @@ -4342,12 +3970,13 @@ check_flush_cache__multi_entry(H5F_t *file_ptr) */ static void -check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, - unsigned int spec_size, struct flush_cache_test_spec spec[]) +check_flush_cache__pe_multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, + unsigned int spec_size, struct pe_flush_cache_test_spec spec[]) { H5C_t *cache_ptr = file_ptr->shared->cache; static char msg[128]; unsigned u; + int j; size_t total_entry_size = 0; test_entry_t *base_addr; test_entry_t *entry_ptr; @@ -4355,20 +3984,20 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int if (cache_ptr == NULL) { pass = false; - snprintf(msg, (size_t)128, "cache_ptr NULL on entry to single entry test #%d.", test_num); + snprintf(msg, (size_t)128, "cache_ptr NULL on entry to pe multi entry test #%d.", test_num); failure_mssg = msg; } else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = false; - snprintf(msg, (size_t)128, "cache not empty at beginning of multi entry test #%d.", test_num); + snprintf(msg, (size_t)128, "cache not empty at beginning of pe multi entry test #%d.", test_num); failure_mssg = msg; } else if ((spec_size < 1) || (spec == NULL)) { pass = false; - snprintf(msg, (size_t)128, "missing/bad test spec on entry to multi entry test #%d.", test_num); + snprintf(msg, (size_t)128, "missing/bad test spec on entry to pe multi entry test #%d.", test_num); failure_mssg = msg; } @@ -4377,10 +4006,12 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int if (((unsigned)spec[u].entry_num != u) || (spec[u].entry_type < 0) || (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[u].entry_index < 0) || - (spec[u].entry_index > max_indices[spec[u].entry_type])) { + (spec[u].entry_index > max_indices[spec[u].entry_type]) || (spec[u].num_pins < 0) || + (spec[u].num_pins > MAX_PINS)) { pass = false; - snprintf(msg, (size_t)128, "bad data in spec[%u] on entry to multi entry test #%d.", u, test_num); + snprintf(msg, (size_t)128, "bad data in spec[%u] on entry to pe multi entry test #%d.", u, + test_num); failure_mssg = msg; } u++; @@ -4388,7 +4019,6 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int u = 0; while (pass && (u < spec_size)) { - if (spec[u].insert_flag) { insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); @@ -4402,6 +4032,12 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int total_entry_size += entry_sizes[spec[u].entry_type]; + for (j = 0; j < spec[u].num_pins; j++) { + + create_pinned_entry_dependency(file_ptr, spec[u].entry_type, spec[u].entry_index, + spec[u].pin_type[j], spec[u].pin_idx[j]); + } + u++; } @@ -4411,14 +4047,15 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int if (!pass) { - snprintf(msg, (size_t)128, "flush with flags 0x%x failed in multi entry test #%d.", flush_flags, - test_num); + snprintf(msg, (size_t)128, "flush with flags 0x%x failed in pe multi entry test #%d.", + flush_flags, test_num); failure_mssg = msg; } } u = 0; while (pass && (u < spec_size)) { + base_addr = entries[spec[u].entry_type]; entry_ptr = &(base_addr[spec[u].entry_index]); @@ -4427,7 +4064,7 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int (entry_ptr->destroyed != spec[u].expected_destroyed)) { pass = false; - snprintf(msg, (size_t)128, "Bad status on entry %u after flush in multi entry test #%d.", u, + snprintf(msg, (size_t)128, "Bad status on entry %u after flush in pe multi entry test #%d.", u, test_num); failure_mssg = msg; } @@ -4442,7 +4079,7 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in multi entry test #%d.", + snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in pe multi entry test #%d.", test_num); failure_mssg = msg; } @@ -4456,13 +4093,13 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int if (!pass) { pass = false; - snprintf(msg, (size_t)128, "Flush failed on cleanup in multi entry test #%d.", test_num); + snprintf(msg, (size_t)128, "Flush failed on cleanup in pe multi entry test #%d.", test_num); failure_mssg = msg; } else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in multi entry test #%d.", + snprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in pe multi entry test #%d.", test_num); failure_mssg = msg; } @@ -4481,237 +4118,75 @@ check_flush_cache__multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int u++; } -} /* check_flush_cache__multi_entry_test() */ +} /* check_flush_cache__pe_multi_entry_test() */ /*------------------------------------------------------------------------- + * Function: check_flush_cache__flush_ops() * - * Function: check_flush_cache__pe_multi_entry_test() + * Purpose: Run the flush ops cache tests. * - * Purpose: Run a multi entry flush cache test. + * These are tests that test the cache's ability to handle + * the case in which the flush callback dirties, resizes, + * and/or moves entries. * - * Return: void + * Do nothing if pass is false on entry. + * + * Return: void * *------------------------------------------------------------------------- */ static void -check_flush_cache__pe_multi_entry_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, - unsigned int spec_size, struct pe_flush_cache_test_spec spec[]) +check_flush_cache__flush_ops(H5F_t *file_ptr) { - H5C_t *cache_ptr = file_ptr->shared->cache; - static char msg[128]; - unsigned u; - int j; - size_t total_entry_size = 0; - test_entry_t *base_addr; - test_entry_t *entry_ptr; + const int max_num_spec = 10; + const int max_num_check = 4; + struct fo_flush_cache_test_spec *spec = NULL; + struct fo_flush_entry_check *checks = NULL; + H5C_t *cache_ptr = file_ptr->shared->cache; if (cache_ptr == NULL) { - pass = false; - snprintf(msg, (size_t)128, "cache_ptr NULL on entry to pe multi entry test #%d.", test_num); - failure_mssg = msg; + pass = false; + failure_mssg = "cache_ptr NULL on entry to flush ops test."; } else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - pass = false; - - snprintf(msg, (size_t)128, "cache not empty at beginning of pe multi entry test #%d.", test_num); - failure_mssg = msg; + pass = false; + failure_mssg = "cache not empty at beginning of flush ops test."; } - else if ((spec_size < 1) || (spec == NULL)) { - pass = false; - snprintf(msg, (size_t)128, "missing/bad test spec on entry to pe multi entry test #%d.", test_num); - failure_mssg = msg; - } + spec = malloc((size_t)max_num_spec * sizeof(struct fo_flush_cache_test_spec)); + if (spec == NULL) { - u = 0; - while (pass && (u < spec_size)) { + pass = false; + failure_mssg = "couldn't allocate flush ops test spec array"; + } - if (((unsigned)spec[u].entry_num != u) || (spec[u].entry_type < 0) || - (spec[u].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[u].entry_index < 0) || - (spec[u].entry_index > max_indices[spec[u].entry_type]) || (spec[u].num_pins < 0) || - (spec[u].num_pins > MAX_PINS)) { + checks = malloc((size_t)max_num_check * sizeof(struct fo_flush_entry_check)); + if (checks == NULL) { - pass = false; - snprintf(msg, (size_t)128, "bad data in spec[%u] on entry to pe multi entry test #%d.", u, - test_num); - failure_mssg = msg; - } - u++; + pass = false; + failure_mssg = "couldn't allocate flush ops test check array"; } - u = 0; - while (pass && (u < spec_size)) { - if (spec[u].insert_flag) { + if (pass) /* test #1 */ + { + /* start with a very simple test, in which there are two entries + * resident in cache, and the second entry dirties the first in + * the flush callback. No size changes, and no flush flags. + */ + int test_num = 1; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 2; + int check_size = 0; + unsigned init_expected_index_len = 2; + size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; + unsigned expected_index_len = 2; + size_t expected_index_size = 2 * PICO_ENTRY_SIZE; - insert_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); - } - else { - - protect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index); - - unprotect_entry(file_ptr, spec[u].entry_type, spec[u].entry_index, spec[u].flags); - } - - total_entry_size += entry_sizes[spec[u].entry_type]; - - for (j = 0; j < spec[u].num_pins; j++) { - - create_pinned_entry_dependency(file_ptr, spec[u].entry_type, spec[u].entry_index, - spec[u].pin_type[j], spec[u].pin_idx[j]); - } - - u++; - } - - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, flush_flags, "dummy failure message.\n") - - if (!pass) { - - snprintf(msg, (size_t)128, "flush with flags 0x%x failed in pe multi entry test #%d.", - flush_flags, test_num); - failure_mssg = msg; - } - } - - u = 0; - while (pass && (u < spec_size)) { - - base_addr = entries[spec[u].entry_type]; - entry_ptr = &(base_addr[spec[u].entry_index]); - - if ((entry_ptr->deserialized != spec[u].expected_deserialized) || - (entry_ptr->serialized != spec[u].expected_serialized) || - (entry_ptr->destroyed != spec[u].expected_destroyed)) { - - pass = false; - snprintf(msg, (size_t)128, "Bad status on entry %u after flush in pe multi entry test #%d.", u, - test_num); - failure_mssg = msg; - } - u++; - } - - if (pass) { - - if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && - ((cache_ptr->index_len != spec_size) || (cache_ptr->index_size != total_entry_size))) || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && - ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { - - pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in pe multi entry test #%d.", - test_num); - failure_mssg = msg; - } - } - - /* clean up the cache to prep for the next test */ - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, "dummy mssg.\n") - - if (!pass) { - - pass = false; - snprintf(msg, (size_t)128, "Flush failed on cleanup in pe multi entry test #%d.", test_num); - failure_mssg = msg; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - - pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size after cleanup in pe multi entry test #%d.", - test_num); - failure_mssg = msg; - } - } - - u = 0; - while (pass && (u < spec_size)) { - - base_addr = entries[spec[u].entry_type]; - entry_ptr = &(base_addr[spec[u].entry_index]); - - entry_ptr->deserialized = false; - entry_ptr->serialized = false; - entry_ptr->destroyed = false; - - u++; - } - -} /* check_flush_cache__pe_multi_entry_test() */ - -/*------------------------------------------------------------------------- - * Function: check_flush_cache__flush_ops() - * - * Purpose: Run the flush ops cache tests. - * - * These are tests that test the cache's ability to handle - * the case in which the flush callback dirties, resizes, - * and/or moves entries. - * - * Do nothing if pass is false on entry. - * - * Return: void - * - *------------------------------------------------------------------------- - */ - -static void -check_flush_cache__flush_ops(H5F_t *file_ptr) -{ - const int max_num_spec = 10; - const int max_num_check = 4; - struct fo_flush_cache_test_spec *spec = NULL; - struct fo_flush_entry_check *checks = NULL; - H5C_t *cache_ptr = file_ptr->shared->cache; - - if (cache_ptr == NULL) { - - pass = false; - failure_mssg = "cache_ptr NULL on entry to flush ops test."; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - - pass = false; - failure_mssg = "cache not empty at beginning of flush ops test."; - } - - spec = malloc((size_t)max_num_spec * sizeof(struct fo_flush_cache_test_spec)); - if (spec == NULL) { - - pass = false; - failure_mssg = "couldn't allocate flush ops test spec array"; - } - - checks = malloc((size_t)max_num_check * sizeof(struct fo_flush_entry_check)); - if (checks == NULL) { - - pass = false; - failure_mssg = "couldn't allocate flush ops test check array"; - } - - if (pass) /* test #1 */ - { - /* start with a very simple test, in which there are two entries - * resident in cache, and the second entry dirties the first in - * the flush callback. No size changes, and no flush flags. - */ - int test_num = 1; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 2; - int check_size = 0; - unsigned init_expected_index_len = 2; - size_t init_expected_index_size = 2 * PICO_ENTRY_SIZE; - unsigned expected_index_len = 2; - size_t expected_index_size = 2 * PICO_ENTRY_SIZE; - - assert(spec_size <= max_num_spec); - assert(check_size <= max_num_check); + assert(spec_size <= max_num_spec); + assert(check_size <= max_num_check); spec[0] = (struct fo_flush_cache_test_spec){ /* entry_num = */ 0, @@ -5927,28 +5402,24 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) if (pass) /* test #21 */ { - /* Now mix things up a bit. + /* Mix things up some more. * - * Load several entries, two of which have flush functions that + * Load lots of entries, some of which have flush functions that * resize, dirty, and move two entries that are not in the - * cache. Mark only one of these entries, and then flush the - * cache with the flush marked entries flag. + * cache. * - * This is the only test in which we test the - * H5C__FLUSH_MARKED_ENTRIES_FLAG. The hope is that since - * we test the two features extensively by themselves, so - * it should be sufficient to verify that they play together - * as expected. + * Also load entries that have flush ops on entries that are in + * cache. */ int test_num = 21; - unsigned int flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; - int spec_size = 4; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 6; int check_size = 4; - unsigned init_expected_index_len = 4; - size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * PICO_ENTRY_SIZE); - unsigned expected_index_len = 6; - size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (VARIABLE_ENTRY_SIZE / 4) + - (VARIABLE_ENTRY_SIZE / 2) + (2 * PICO_ENTRY_SIZE); + unsigned init_expected_index_len = 6; + size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); + unsigned expected_index_len = 10; + size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * (VARIABLE_ENTRY_SIZE / 4)) + + (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * PICO_ENTRY_SIZE); assert(spec_size <= max_num_spec); assert(check_size <= max_num_check); @@ -5958,7 +5429,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) /* entry_type = */ VARIABLE_ENTRY_TYPE, /* entry_index = */ 1, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__DIRTIED_FLAG, /* resize_flag = */ false, /* new_size = */ 0, /* num_pins = */ 0, @@ -6005,14 +5476,14 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, /* expected_deserialized = */ true, - /* expected_serialized = */ false, + /* expected_serialized = */ true, /* expected_destroyed = */ false}; spec[2] = (struct fo_flush_cache_test_spec){ /* entry_num = */ 2, /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 0, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, /* resize_flag = */ false, /* new_size = */ 0, /* num_pins = */ 0, @@ -6039,7 +5510,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) /* entry_type = */ PICO_ENTRY_TYPE, /* entry_index = */ 1, /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, + /* flags = */ H5C__NO_FLAGS_SET, /* resize_flag = */ false, /* new_size = */ 0, /* num_pins = */ 0, @@ -6061,6 +5532,60 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) /* expected_deserialized = */ true, /* expected_serialized = */ false, /* expected_destroyed = */ false}; + spec[4] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 4, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 10, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; + spec[5] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 5, + /* entry_type = */ PICO_ENTRY_TYPE, + /* entry_index = */ 20, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 1, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, /* entry_type = */ VARIABLE_ENTRY_TYPE, @@ -6068,11 +5593,11 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, /* in_cache = */ true, /* at_main_addr = */ false, - /* is_dirty = */ true, + /* is_dirty = */ false, /* is_protected = */ false, /* is_pinned = */ false, /* expected_deserialized = */ true, - /* expected_serialized = */ false, + /* expected_serialized = */ true, /* expected_destroyed = */ false}; checks[1] = (struct fo_flush_entry_check){/* entry_num = */ 1, /* entry_type = */ VARIABLE_ENTRY_TYPE, @@ -6080,272 +5605,30 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, /* in_cache = */ true, /* at_main_addr = */ false, - /* is_dirty = */ true, + /* is_dirty = */ false, /* is_protected = */ false, /* is_pinned = */ false, /* expected_deserialized = */ true, - /* expected_serialized = */ false, + /* expected_serialized = */ true, /* expected_destroyed = */ false}; checks[2] = (struct fo_flush_entry_check){/* entry_num = */ 2, /* entry_type = */ VARIABLE_ENTRY_TYPE, /* entry_index = */ 10, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ false, - /* at_main_addr = */ true, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, + /* in_cache = */ true, + /* at_main_addr = */ false, /* is_dirty = */ false, /* is_protected = */ false, /* is_pinned = */ false, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, /* expected_destroyed = */ false}; checks[3] = (struct fo_flush_entry_check){/* entry_num = */ 3, /* entry_type = */ VARIABLE_ENTRY_TYPE, /* entry_index = */ 12, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ false, - /* at_main_addr = */ true, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}; - - check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, - init_expected_index_len, init_expected_index_size, - expected_index_len, expected_index_size, check_size, checks); - reset_entries(); - } - - if (pass) /* test #22 */ - { - /* Mix things up some more. - * - * Load lots of entries, some of which have flush functions that - * resize, dirty, and move two entries that are not in the - * cache. - * - * Also load entries that have flush ops on entries that are in - * cache. - */ - int test_num = 22; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 6; - int check_size = 4; - unsigned init_expected_index_len = 6; - size_t init_expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (4 * PICO_ENTRY_SIZE); - unsigned expected_index_len = 10; - size_t expected_index_size = (2 * VARIABLE_ENTRY_SIZE) + (2 * (VARIABLE_ENTRY_SIZE / 4)) + - (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * PICO_ENTRY_SIZE); - - assert(spec_size <= max_num_spec); - assert(check_size <= max_num_check); - - spec[0] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, false, VARIABLE_ENTRY_SIZE / 4, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, 0, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 2, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 2, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[1] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 11, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 6, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 10, false, VARIABLE_ENTRY_SIZE / 4, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 10, false, 0, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 10, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 12, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 12, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 12, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[2] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 2, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 0, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[3] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 3, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 1, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}; - spec[4] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 4, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 10, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[5] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 5, - /* entry_type = */ PICO_ENTRY_TYPE, - /* entry_index = */ 20, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 1, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, PICO_ENTRY_TYPE, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - - checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 0, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ true, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - checks[1] = (struct fo_flush_entry_check){/* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ true, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - checks[2] = (struct fo_flush_entry_check){/* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 10, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 4, - /* in_cache = */ true, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - checks[3] = (struct fo_flush_entry_check){/* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 12, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ true, - /* at_main_addr = */ false, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ true, + /* at_main_addr = */ false, /* is_dirty = */ false, /* is_protected = */ false, /* is_pinned = */ false, @@ -6359,9 +5642,9 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) reset_entries(); } - if (pass) /* test #23 */ + if (pass) /* test #22 */ { - /* Repeat test #23 with the flush invalidate flag set. + /* Repeat test #21 with the flush invalidate flag set. * * Mix things up some more. * @@ -6372,7 +5655,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) * Also load entries that have flush ops on entries that are in * cache. */ - int test_num = 23; + int test_num = 22; unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; int spec_size = 6; int check_size = 4; @@ -6606,12 +5889,12 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) * * Now create some tests mixing flush ops and pins. */ - if (pass) /* test #24 */ + if (pass) /* test #23 */ { /* Pico entries 50 and 150 pin pico entry 100, and also dirty * pico entry 100 on flush. */ - int test_num = 24; + int test_num = 23; unsigned int flush_flags = H5C__NO_FLAGS_SET; int spec_size = 3; int check_size = 0; @@ -6723,14 +6006,14 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) expected_index_len, expected_index_size, check_size, checks); } - if (pass) /* test #25 */ + if (pass) /* test #24 */ { /* Repeat the previous test with the flush invalidate flag. * * Pico entries 50 and 150 pin pico entry 100, and also dirty * pico entry 100 on flush. */ - int test_num = 25; + int test_num = 24; unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; int spec_size = 3; int check_size = 0; @@ -6842,7 +6125,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) expected_index_len, expected_index_size, check_size, checks); } - if (pass) /* test #26 */ + if (pass) /* test #25 */ { /* This one is complex. * @@ -6919,7 +6202,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) * dirties (VET, 650) * dirties (VET, 750) */ - int test_num = 26; + int test_num = 25; unsigned int flush_flags = H5C__NO_FLAGS_SET; int spec_size = 10; int check_size = 3; @@ -7246,9 +6529,9 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) reset_entries(); } - if (pass) /* test #27 */ + if (pass) /* test #26 */ { - /* Repeat test #26 with the flush invalidate flag. + /* Repeat test #25 with the flush invalidate flag. * * In the following overview table, VET stands for * VARIABLE_ENTRY_TYPE. @@ -7327,7 +6610,7 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) * dirties (VET, 650) * dirties (VET, 750) */ - int test_num = 27; + int test_num = 26; unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; int spec_size = 10; int check_size = 3; @@ -7547,1790 +6830,1139 @@ check_flush_cache__flush_ops(H5F_t *file_ptr) {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 650, false, VARIABLE_ENTRY_SIZE / 4, NULL}, {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ false, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[8] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 8, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 750, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 2, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, false, VARIABLE_ENTRY_SIZE / 4, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[9] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 9, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 4, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, false, 0, NULL}, - {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - - checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ false, - /* at_main_addr = */ true, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - checks[1] = (struct fo_flush_entry_check){/* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* expected_size = */ VARIABLE_ENTRY_SIZE, - /* in_cache = */ false, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - checks[2] = (struct fo_flush_entry_check){/* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 2200, - /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, - /* in_cache = */ false, - /* at_main_addr = */ true, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - - check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, - init_expected_index_len, init_expected_index_size, - expected_index_len, expected_index_size, check_size, checks); - - reset_entries(); - } - - if (pass) /* test #28 */ - { - /* Test the expected fheap case, in which an entry dirties - * and resizes itself, and dirties an entry which it has - * pinned. - */ - int test_num = 28; - unsigned int flush_flags = H5C__NO_FLAGS_SET; - int spec_size = 5; - int check_size = 0; - unsigned init_expected_index_len = 5; - size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 5; - size_t expected_index_size = 4 * VARIABLE_ENTRY_SIZE; - - assert(spec_size <= max_num_spec); - assert(check_size <= max_num_check); - - spec[0] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[1] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, false, VARIABLE_ENTRY_SIZE, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[2] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[3] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 400, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - spec[4] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ false}; - - checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ 0, - /* in_cache = */ false, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}; - - check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, - init_expected_index_len, init_expected_index_size, - expected_index_len, expected_index_size, check_size, checks); - - reset_entries(); - } - - if (pass) /* test #29 */ - { - /* Repeat test #28 with the flush invalidate flag. - * - * Test the expected fheap case, in which an entry dirties - * and resizes itself, and dirties an entry which it has - * pinned. - */ - int test_num = 29; - unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; - int spec_size = 5; - int check_size = 0; - unsigned init_expected_index_len = 5; - size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; - unsigned expected_index_len = 0; - size_t expected_index_size = 0; - - assert(spec_size <= max_num_spec); - assert(check_size <= max_num_check); - - spec[0] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 0, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 100, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[1] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 1, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 200, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 2, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, false, VARIABLE_ENTRY_SIZE, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[2] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 2, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 300, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[3] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 3, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 400, - /* insert_flag = */ false, - /* flags = */ H5C__NO_FLAGS_SET, - /* resize_flag = */ false, - /* new_size = */ 0, - /* num_pins = */ 0, - /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 0, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - spec[4] = (struct fo_flush_cache_test_spec){ - /* entry_num = */ 4, - /* entry_type = */ VARIABLE_ENTRY_TYPE, - /* entry_index = */ 500, - /* insert_flag = */ false, - /* flags = */ H5C__DIRTIED_FLAG, - /* resize_flag = */ true, - /* new_size = */ VARIABLE_ENTRY_SIZE / 4, - /* num_pins = */ 1, - /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, - /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, - /* num_flush_ops = */ 3, - /* flush_ops = */ - /* op_code: type: idx: flag: size: order_ptr: */ - {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, - {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, false, VARIABLE_ENTRY_SIZE / 2, NULL}, - {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, - {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, - /* expected_deserialized = */ true, - /* expected_serialized = */ true, - /* expected_destroyed = */ true}; - - checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, - /* entry_type = */ 0, - /* entry_index = */ 0, - /* expected_size = */ 0, - /* in_cache = */ false, - /* at_main_addr = */ false, - /* is_dirty = */ false, - /* is_protected = */ false, - /* is_pinned = */ false, - /* expected_deserialized = */ false, - /* expected_serialized = */ false, - /* expected_destroyed = */ false}; - - check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, - init_expected_index_len, init_expected_index_size, - expected_index_len, expected_index_size, check_size, checks); - - reset_entries(); - } - - free(checks); - free(spec); - - /* finally finish up with the flush ops eviction test */ - check_flush_cache__flush_op_eviction_test(file_ptr); - -} /* check_flush_cache__flush_ops() */ - -/*------------------------------------------------------------------------- - * Function: check_flush_cache__flush_op_test() - * - * Purpose: Run a flush op flush cache test. Of the nature of - * flush operations, this is a multi-entry test. - * - * Return: void - * - *------------------------------------------------------------------------- - */ - -static void -check_flush_cache__flush_op_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, int spec_size, - const struct fo_flush_cache_test_spec spec[], - unsigned init_expected_index_len, size_t init_expected_index_size, - unsigned expected_index_len, size_t expected_index_size, int check_size, - struct fo_flush_entry_check check[]) -{ - H5C_t *cache_ptr = file_ptr->shared->cache; - static char msg[128]; - int i; - int j; - test_entry_t *base_addr; - test_entry_t *entry_ptr; - - if (cache_ptr == NULL) { - - pass = false; - snprintf(msg, (size_t)128, "cache_ptr NULL on entry to flush op test #%d.", test_num); - failure_mssg = msg; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - - pass = false; - - snprintf(msg, (size_t)128, "cache not empty at beginning of flush op test #%d.", test_num); - failure_mssg = msg; - } - else if ((spec_size < 1) || (spec == NULL)) { - - pass = false; - snprintf(msg, (size_t)128, "missing/bad test spec on entry to flush op test #%d.", test_num); - failure_mssg = msg; - } - - i = 0; - while (pass && (i < spec_size)) { - - if ((spec[i].entry_num != i) || (spec[i].entry_type < 0) || - (spec[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[i].entry_index < 0) || - (spec[i].entry_index > max_indices[spec[i].entry_type]) || (spec[i].num_pins < 0) || - (spec[i].num_pins > MAX_PINS) || (spec[i].num_flush_ops < 0) || - (spec[i].num_flush_ops > MAX_FLUSH_OPS)) { - - pass = false; - snprintf(msg, (size_t)128, "bad data in spec[%d] on entry to flush op test #%d.", i, test_num); - failure_mssg = msg; - } - i++; - } - - i = 0; - while (pass && (i < check_size)) { - - if ((check[i].entry_num != i) || (check[i].entry_type < 0) || - (check[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (check[i].entry_index < 0) || - (check[i].entry_index > max_indices[check[i].entry_type]) || - (check[i].expected_size <= (size_t)0)) { - - pass = false; - snprintf(msg, (size_t)128, "bad data in check[%d] on entry to flush op test #%d.", i, test_num); - failure_mssg = msg; - } - i++; - } - - i = 0; - while (pass && (i < spec_size)) { - - if (spec[i].insert_flag) { - - insert_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); - } - else { - - protect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index); - - if (spec[i].resize_flag) - resize_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].new_size, true); - - unprotect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); - } - - for (j = 0; j < spec[i].num_pins; j++) { - create_pinned_entry_dependency(file_ptr, spec[i].entry_type, spec[i].entry_index, - spec[i].pin_type[j], spec[i].pin_idx[j]); - } - - for (j = 0; j < spec[i].num_flush_ops; j++) { - - add_flush_op(spec[i].entry_type, spec[i].entry_index, spec[i].flush_ops[j].op_code, - spec[i].flush_ops[j].type, spec[i].flush_ops[j].idx, spec[i].flush_ops[j].flag, - spec[i].flush_ops[j].size, spec[i].flush_ops[j].order_ptr); - } - - i++; - } - - if (pass) { - - if ((cache_ptr->index_len != init_expected_index_len) || - (cache_ptr->index_size != init_expected_index_size)) { - - pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size before flush in flush op test #%d.", - test_num); - failure_mssg = msg; - } - } - - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, flush_flags, "dummy failure message") - - if (!pass) { - - pass = false; - snprintf(msg, (size_t)128, "flush with flags 0x%x failed in flush op test #%d.", flush_flags, - test_num); - failure_mssg = msg; - } - } - - i = 0; - while (pass && (i < spec_size)) { - - base_addr = entries[spec[i].entry_type]; - entry_ptr = &(base_addr[spec[i].entry_index]); - - if ((entry_ptr->deserialized != spec[i].expected_deserialized) || - (entry_ptr->serialized != spec[i].expected_serialized) || - (entry_ptr->destroyed != spec[i].expected_destroyed)) { - - pass = false; - snprintf(msg, (size_t)128, "Bad status on entry %d after flush op test #%d.", i, test_num); - failure_mssg = msg; - } - i++; - } - - if (pass) { - - i = 0; - while (pass && (i < check_size)) { - - if (check[i].in_cache != entry_in_cache(cache_ptr, check[i].entry_type, check[i].entry_index)) { - - pass = false; - snprintf(msg, (size_t)128, "Check1 failed on entry %d after flush op test #%d.", i, test_num); - failure_mssg = msg; - } - - base_addr = entries[check[i].entry_type]; - entry_ptr = &(base_addr[check[i].entry_index]); - - if ((entry_ptr->size != check[i].expected_size) || - ((!entry_ptr->header.destroy_in_progress) && (check[i].in_cache) && - (entry_ptr->header.size != check[i].expected_size)) || - (entry_ptr->at_main_addr != check[i].at_main_addr) || - (entry_ptr->is_dirty != check[i].is_dirty) || - (entry_ptr->header.is_dirty != check[i].is_dirty) || - (entry_ptr->is_protected != check[i].is_protected) || - (entry_ptr->header.is_protected != check[i].is_protected) || - (entry_ptr->is_pinned != check[i].is_pinned) || - (entry_ptr->header.is_pinned != check[i].is_pinned) || - (entry_ptr->deserialized != check[i].expected_deserialized) || - (entry_ptr->serialized != check[i].expected_serialized) || - (entry_ptr->destroyed != check[i].expected_destroyed)) { - - pass = false; - snprintf(msg, (size_t)128, "Check2 failed on entry %d after flush op test #%d.", i, test_num); - failure_mssg = msg; - } - i++; - } - } - - if (pass) { - - if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && - ((cache_ptr->index_len != expected_index_len) || - (cache_ptr->index_size != expected_index_size))) || - (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && - ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { - - pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in flush op test #%d.", - test_num); - failure_mssg = msg; - } - } - - /* clean up the cache to prep for the next test */ - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, "dummy mssg.") - - if (!pass) { - - snprintf(msg, (size_t)128, "Flush failed on cleanup in flush op test #%d.", test_num); - failure_mssg = msg; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || - (cache_ptr->clean_index_size != 0) || (cache_ptr->dirty_index_size != 0)) { - - pass = false; - snprintf(msg, (size_t)128, "Unexpected cache len/size/cs/ds after cleanup in flush op test #%d.", - test_num); - failure_mssg = msg; - } - } - - i = 0; - while (pass && (i < spec_size)) { - - base_addr = entries[spec[i].entry_type]; - entry_ptr = &(base_addr[spec[i].entry_index]); + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ false, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[8] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 8, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 750, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 2, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {1000, 2000, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 1000, false, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 2000, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 750, false, VARIABLE_ENTRY_SIZE / 4, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[9] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 9, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 4, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 350, false, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 450, false, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 650, false, 0, NULL}, + {FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 750, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; - entry_ptr->size = entry_sizes[spec[i].entry_type]; + checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ false, + /* at_main_addr = */ true, + /* is_dirty = */ false, + /* is_protected = */ false, + /* is_pinned = */ false, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + checks[1] = (struct fo_flush_entry_check){/* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* expected_size = */ VARIABLE_ENTRY_SIZE, + /* in_cache = */ false, + /* at_main_addr = */ false, + /* is_dirty = */ false, + /* is_protected = */ false, + /* is_pinned = */ false, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + checks[2] = (struct fo_flush_entry_check){/* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 2200, + /* expected_size = */ VARIABLE_ENTRY_SIZE / 2, + /* in_cache = */ false, + /* at_main_addr = */ true, + /* is_dirty = */ false, + /* is_protected = */ false, + /* is_pinned = */ false, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; - entry_ptr->deserialized = false; - entry_ptr->serialized = false; - entry_ptr->destroyed = false; + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - i++; + reset_entries(); } - i = 0; - while (pass && (i < check_size)) { - - base_addr = entries[check[i].entry_type]; - entry_ptr = &(base_addr[check[i].entry_index]); - - entry_ptr->size = entry_sizes[check[i].entry_type]; - - entry_ptr->deserialized = false; - entry_ptr->serialized = false; - entry_ptr->destroyed = false; - - i++; - } + if (pass) /* test #27 */ + { + /* Test the expected fheap case, in which an entry dirties + * and resizes itself, and dirties an entry which it has + * pinned. + */ + int test_num = 27; + unsigned int flush_flags = H5C__NO_FLAGS_SET; + int spec_size = 5; + int check_size = 0; + unsigned init_expected_index_len = 5; + size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 5; + size_t expected_index_size = 4 * VARIABLE_ENTRY_SIZE; -} /* check_flush_cache__flush_op_test() */ + assert(spec_size <= max_num_spec); + assert(check_size <= max_num_check); -/*------------------------------------------------------------------------- - * Function: check_flush_cache__flush_op_eviction_test() - * - * Purpose: Verify that flush operations work as expected when an - * entry is evicted. - * - * Do nothing if pass is false on entry. - * - * Return: void - * - *------------------------------------------------------------------------- - */ + spec[0] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; + spec[1] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, false, VARIABLE_ENTRY_SIZE, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; + spec[2] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, false, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; + spec[3] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 400, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; + spec[4] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, false, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ false}; -static void -check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) -{ - struct expected_entry_status *expected = NULL; - H5C_t *cache_ptr = file_ptr->shared->cache; - int i; - const int num_variable_entries = 10; - const int num_monster_entries = 31; - int num_large_entries = 14; - const int num_total_entries = num_variable_entries + num_monster_entries + num_large_entries; - test_entry_t *entry_ptr; - test_entry_t *base_addr; + checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ 0, + /* in_cache = */ false, + /* at_main_addr = */ false, + /* is_dirty = */ false, + /* is_protected = */ false, + /* is_pinned = */ false, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}; - expected = malloc((size_t)num_total_entries * sizeof(struct expected_entry_status)); - if (expected == NULL) { + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - pass = false; - failure_mssg = "couldn't allocate expected entry status array\n"; + reset_entries(); } - if (expected) { - /* the expected array is used to maintain a table of the expected status of every - * entry used in this test. Note that since the function that processes this - * array only processes as much of it as it is told to, we don't have to - * worry about maintaining the status of entries that we haven't used yet. + if (pass) /* test #28 */ + { + /* Repeat test #27 with the flush invalidate flag. + * + * Test the expected fheap case, in which an entry dirties + * and resizes itself, and dirties an entry which it has + * pinned. */ - for (i = 0; i < num_variable_entries; i++) { - expected[i].entry_type = VARIABLE_ENTRY_TYPE; - expected[i].entry_index = (int)(i); - expected[i].size = VARIABLE_ENTRY_SIZE; - expected[i].in_cache = true; - expected[i].at_main_addr = true; - expected[i].is_dirty = true; - expected[i].is_protected = false; - expected[i].is_pinned = false; - expected[i].deserialized = true; - expected[i].serialized = false; - expected[i].destroyed = false; - - memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); - memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); - - expected[i].flush_dep_npar = 0; - expected[i].flush_dep_nchd = 0; - expected[i].flush_dep_ndirty_chd = 0; - expected[i].flush_order = -1; - expected[i].is_corked = false; - } - - /* NOTE: special cases for particular variable entries */ - expected[0].size = VARIABLE_ENTRY_SIZE / 4; - expected[0].is_pinned = true; - - expected[1].size = VARIABLE_ENTRY_SIZE / 4; - - expected[2].is_dirty = false; - - expected[3].size = VARIABLE_ENTRY_SIZE / 4; + int test_num = 28; + unsigned int flush_flags = H5C__FLUSH_INVALIDATE_FLAG; + int spec_size = 5; + int check_size = 0; + unsigned init_expected_index_len = 5; + size_t init_expected_index_size = 3 * VARIABLE_ENTRY_SIZE; + unsigned expected_index_len = 0; + size_t expected_index_size = 0; - expected[4].is_dirty = false; + assert(spec_size <= max_num_spec); + assert(check_size <= max_num_check); - expected[5].size = VARIABLE_ENTRY_SIZE / 4; + spec[0] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 0, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 100, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[1] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 1, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 200, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 2, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 200, false, VARIABLE_ENTRY_SIZE, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 200, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[2] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 2, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 300, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {400, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 400, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 300, false, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 300, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[3] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 3, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 400, + /* insert_flag = */ false, + /* flags = */ H5C__NO_FLAGS_SET, + /* resize_flag = */ false, + /* new_size = */ 0, + /* num_pins = */ 0, + /* pin_type = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {0, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 0, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; + spec[4] = (struct fo_flush_cache_test_spec){ + /* entry_num = */ 4, + /* entry_type = */ VARIABLE_ENTRY_TYPE, + /* entry_index = */ 500, + /* insert_flag = */ false, + /* flags = */ H5C__DIRTIED_FLAG, + /* resize_flag = */ true, + /* new_size = */ VARIABLE_ENTRY_SIZE / 4, + /* num_pins = */ 1, + /* pin_type = */ {VARIABLE_ENTRY_TYPE, 0, 0, 0, 0, 0, 0, 0}, + /* pin_idx = */ {100, 0, 0, 0, 0, 0, 0, 0}, + /* num_flush_ops = */ 3, + /* flush_ops = */ + /* op_code: type: idx: flag: size: order_ptr: */ + {{FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 100, false, 0, NULL}, + {FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 500, false, VARIABLE_ENTRY_SIZE / 2, NULL}, + {FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 500, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}, + {FLUSH_OP__NO_OP, 0, 0, false, 0, NULL}}, + /* expected_deserialized = */ true, + /* expected_serialized = */ true, + /* expected_destroyed = */ true}; - expected[6].size = VARIABLE_ENTRY_SIZE / 2; + checks[0] = (struct fo_flush_entry_check){/* entry_num = */ 0, + /* entry_type = */ 0, + /* entry_index = */ 0, + /* expected_size = */ 0, + /* in_cache = */ false, + /* at_main_addr = */ false, + /* is_dirty = */ false, + /* is_protected = */ false, + /* is_pinned = */ false, + /* expected_deserialized = */ false, + /* expected_serialized = */ false, + /* expected_destroyed = */ false}; - expected[7].size = VARIABLE_ENTRY_SIZE / 2; + check_flush_cache__flush_op_test(file_ptr, test_num, flush_flags, spec_size, spec, + init_expected_index_len, init_expected_index_size, + expected_index_len, expected_index_size, check_size, checks); - expected[8].is_dirty = false; + reset_entries(); + } - expected[9].is_dirty = false; - expected[9].is_pinned = true; + free(checks); + free(spec); - for (; i < num_variable_entries + num_monster_entries; i++) { - expected[i].entry_type = MONSTER_ENTRY_TYPE; - expected[i].entry_index = (int)(i - num_variable_entries); - expected[i].size = MONSTER_ENTRY_SIZE; - expected[i].in_cache = true; - expected[i].at_main_addr = true; - expected[i].is_dirty = true; - expected[i].is_protected = false; - expected[i].is_pinned = false; - expected[i].deserialized = true; - expected[i].serialized = false; - expected[i].destroyed = false; + /* finally finish up with the flush ops eviction test */ + check_flush_cache__flush_op_eviction_test(file_ptr); - memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); - memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); +} /* check_flush_cache__flush_ops() */ - expected[i].flush_dep_npar = 0; - expected[i].flush_dep_nchd = 0; - expected[i].flush_dep_ndirty_chd = 0; - expected[i].flush_order = -1; - expected[i].is_corked = false; - } +/*------------------------------------------------------------------------- + * Function: check_flush_cache__flush_op_test() + * + * Purpose: Run a flush op flush cache test. Of the nature of + * flush operations, this is a multi-entry test. + * + * Return: void + * + *------------------------------------------------------------------------- + */ - for (; i < num_total_entries; i++) { - expected[i].entry_type = LARGE_ENTRY_TYPE; - expected[i].entry_index = (int)(i - num_monster_entries - num_variable_entries); - expected[i].size = LARGE_ENTRY_SIZE; - expected[i].in_cache = true; - expected[i].at_main_addr = true; - expected[i].is_dirty = true; - expected[i].is_protected = false; - expected[i].is_pinned = false; - expected[i].deserialized = true; - expected[i].serialized = false; - expected[i].destroyed = false; +static void +check_flush_cache__flush_op_test(H5F_t *file_ptr, int test_num, unsigned int flush_flags, int spec_size, + const struct fo_flush_cache_test_spec spec[], + unsigned init_expected_index_len, size_t init_expected_index_size, + unsigned expected_index_len, size_t expected_index_size, int check_size, + struct fo_flush_entry_check check[]) +{ + H5C_t *cache_ptr = file_ptr->shared->cache; + static char msg[128]; + int i; + int j; + test_entry_t *base_addr; + test_entry_t *entry_ptr; - memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); - memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); + if (cache_ptr == NULL) { - expected[i].flush_dep_npar = 0; - expected[i].flush_dep_nchd = 0; - expected[i].flush_dep_ndirty_chd = 0; - expected[i].flush_order = -1; - expected[i].is_corked = false; - } + pass = false; + snprintf(msg, (size_t)128, "cache_ptr NULL on entry to flush op test #%d.", test_num); + failure_mssg = msg; + } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - assert(i == num_total_entries); + pass = false; - pass = true; + snprintf(msg, (size_t)128, "cache not empty at beginning of flush op test #%d.", test_num); + failure_mssg = msg; } + else if ((spec_size < 1) || (spec == NULL)) { - if (pass) { + pass = false; + snprintf(msg, (size_t)128, "missing/bad test spec on entry to flush op test #%d.", test_num); + failure_mssg = msg; + } - if (cache_ptr == NULL) { + i = 0; + while (pass && (i < spec_size)) { - pass = false; - failure_mssg = "cache_ptr NULL on entry to flush ops test."; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { + if ((spec[i].entry_num != i) || (spec[i].entry_type < 0) || + (spec[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (spec[i].entry_index < 0) || + (spec[i].entry_index > max_indices[spec[i].entry_type]) || (spec[i].num_pins < 0) || + (spec[i].num_pins > MAX_PINS) || (spec[i].num_flush_ops < 0) || + (spec[i].num_flush_ops > MAX_FLUSH_OPS)) { - pass = false; - failure_mssg = "cache not empty at start of flush ops eviction test."; + pass = false; + snprintf(msg, (size_t)128, "bad data in spec[%d] on entry to flush op test #%d.", i, test_num); + failure_mssg = msg; } - else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || - (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { + i++; + } - pass = false; - failure_mssg = "unexpected cache config at start of flush op eviction test."; - } - else { + i = 0; + while (pass && (i < check_size)) { - /* set min clean size to zero for this test as it simplifies - * computing the expected cache size after each operation. - */ + if ((check[i].entry_num != i) || (check[i].entry_type < 0) || + (check[i].entry_type >= NUMBER_OF_ENTRY_TYPES) || (check[i].entry_index < 0) || + (check[i].entry_index > max_indices[check[i].entry_type]) || + (check[i].expected_size <= (size_t)0)) { - cache_ptr->min_clean_size = 0; + pass = false; + snprintf(msg, (size_t)128, "bad data in check[%d] on entry to flush op test #%d.", i, test_num); + failure_mssg = msg; } + i++; } - if (pass) { - - /* the basic idea in this test is to insert a bunch of entries - * with flush operations associated with them, and then load - * other entries into the cache until the cache is full. At - * that point, load yet more entries into the cache, and see - * if the flush operations are performed as expected. - * - * To make things a bit more interesting, we also include a - * couple of pins. - */ - - /* reset the stats before we start. If stats are enabled, we will - * check to see if they are as expected at the end. - */ - H5C_stats__reset(cache_ptr); - - /* load a few entries with pin relationships and flush ops. - * Start by just loading the entries. - */ + i = 0; + while (pass && (i < spec_size)) { - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, (VARIABLE_ENTRY_SIZE / 4), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); + if (spec[i].insert_flag) { - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, (VARIABLE_ENTRY_SIZE / 4), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); + insert_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); + } + else { - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, (VARIABLE_ENTRY_SIZE / 4), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); + if (spec[i].resize_flag) + resize_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].new_size, true); - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4, H5C__NO_FLAGS_SET); + unprotect_entry(file_ptr, spec[i].entry_type, spec[i].entry_index, spec[i].flags); + } - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, (VARIABLE_ENTRY_SIZE / 4), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, H5C__DIRTIED_FLAG); + for (j = 0; j < spec[i].num_pins; j++) { + create_pinned_entry_dependency(file_ptr, spec[i].entry_type, spec[i].entry_index, + spec[i].pin_type[j], spec[i].pin_idx[j]); + } - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, (VARIABLE_ENTRY_SIZE / 2), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, H5C__DIRTIED_FLAG); + for (j = 0; j < spec[i].num_flush_ops; j++) { - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7); - resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, (VARIABLE_ENTRY_SIZE / 2), true); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, H5C__DIRTIED_FLAG); + add_flush_op(spec[i].entry_type, spec[i].entry_index, spec[i].flush_ops[j].op_code, + spec[i].flush_ops[j].type, spec[i].flush_ops[j].idx, spec[i].flush_ops[j].flag, + spec[i].flush_ops[j].size, spec[i].flush_ops[j].order_ptr); + } - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__NO_FLAGS_SET); + i++; + } - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); + if (pass) { - if ((cache_ptr->index_len != 10) || - (cache_ptr->index_size != - (4 * (VARIABLE_ENTRY_SIZE / 4)) + (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * VARIABLE_ENTRY_SIZE))) { + if ((cache_ptr->index_len != init_expected_index_len) || + (cache_ptr->index_size != init_expected_index_size)) { - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 1."; + pass = false; + snprintf(msg, (size_t)128, "Unexpected cache len/size before flush in flush op test #%d.", + test_num); + failure_mssg = msg; } } if (pass) { - /* Now set up the pinning relationships: - * - * Briefly, (VET, 0) is pinned by (VET, 1), (VET, 3), and (VET, 5) - * (VET, 9) is pinned by (VET, 5), and (VET, 7) - */ - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 0); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 9); - create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_TYPE, 9); + H5C_FLUSH_CACHE(file_ptr, flush_flags, "dummy failure message") - /* Next, set up the flush operations: - * - * Briefly, (VET, 1) dirties (VET, 0) - * resizes (VET, 0) to 3/4 VARIABLE_ENTRY_SIZE - * - * (VET, 3) dirties (VET, 0) - * resizes (VET, 0) to VARIABLE_ENTRY_SIZE - * moves (VET, 0) to its alternate address - * - * (VET, 5) dirties (VET, 0) - * resizes itself to VARIABLE_ENTRY_SIZE / 2 - * - * (VET, 7) dirties (VET, 9) - * - * (VET, 9) dirties (VET, 8) - */ - add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, true, - 3 * VARIABLE_ENTRY_SIZE / 4, NULL); + if (!pass) { + + pass = false; + snprintf(msg, (size_t)128, "flush with flags 0x%x failed in flush op test #%d.", flush_flags, + test_num); + failure_mssg = msg; + } + } - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, true, - VARIABLE_ENTRY_SIZE, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); + i = 0; + while (pass && (i < spec_size)) { - add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); - add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 5, true, - VARIABLE_ENTRY_SIZE / 2, NULL); + base_addr = entries[spec[i].entry_type]; + entry_ptr = &(base_addr[spec[i].entry_index]); - add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 9, false, (size_t)0, NULL); + if ((entry_ptr->deserialized != spec[i].expected_deserialized) || + (entry_ptr->serialized != spec[i].expected_serialized) || + (entry_ptr->destroyed != spec[i].expected_destroyed)) { - add_flush_op(VARIABLE_ENTRY_TYPE, 9, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 8, false, (size_t)0, NULL); + pass = false; + snprintf(msg, (size_t)128, "Bad status on entry %d after flush op test #%d.", i, test_num); + failure_mssg = msg; + } + i++; } if (pass) { - /* to summarize, at present the following variable size entries - * are in cache with the following characteristics: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 2.5 KB Y Y - - - * - * (VET, 1) Y 2.5 KB Y N 0 dirty (VET, 0), - * resize (VET, 0) to 7.5 KB - * - * (VET, 2) Y 10 KB N N - - - * - * - * (VET, 3) Y 2.5 KB N N 0 dirty (VET, 0) - * resize (VET, 0) to 10 KB - * move (VET, 0) to its alternate address - * - * (VET, 4) Y 10 KB N N - - - * - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N N - dirty (VET, 8) - * - * Recall that in this test bed, flush operations are executed the - * first time the associated entry is flushed, and are then - * deleted. - */ + i = 0; + while (pass && (i < check_size)) { - /* Now fill up the cache with other, unrelated entries */ - for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + if (check[i].in_cache != entry_in_cache(cache_ptr, check[i].entry_type, check[i].entry_index)) { - for (i = 0; i < 1; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + pass = false; + snprintf(msg, (size_t)128, "Check1 failed on entry %d after flush op test #%d.", i, test_num); + failure_mssg = msg; + } - /* The cache should now be exactly full */ - if ((cache_ptr->index_len != 42) || (cache_ptr->index_size != 2 * 1024 * 1024) || - (cache_ptr->index_size != - ((4 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (4 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (1 * LARGE_ENTRY_SIZE)))) { + base_addr = entries[check[i].entry_type]; + entry_ptr = &(base_addr[check[i].entry_index]); - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 2."; - } - else { + if ((entry_ptr->size != check[i].expected_size) || + ((!entry_ptr->header.destroy_in_progress) && (check[i].in_cache) && + (entry_ptr->header.size != check[i].expected_size)) || + (entry_ptr->at_main_addr != check[i].at_main_addr) || + (entry_ptr->is_dirty != check[i].is_dirty) || + (entry_ptr->header.is_dirty != check[i].is_dirty) || + (entry_ptr->is_protected != check[i].is_protected) || + (entry_ptr->header.is_protected != check[i].is_protected) || + (entry_ptr->is_pinned != check[i].is_pinned) || + (entry_ptr->header.is_pinned != check[i].is_pinned) || + (entry_ptr->deserialized != check[i].expected_deserialized) || + (entry_ptr->serialized != check[i].expected_serialized) || + (entry_ptr->destroyed != check[i].expected_destroyed)) { - /* verify the expected status of all entries we have loaded to date: */ - num_large_entries = 1; - verify_entry_status(cache_ptr, 0, - (num_variable_entries + num_monster_entries + num_large_entries), expected); + pass = false; + snprintf(msg, (size_t)128, "Check2 failed on entry %d after flush op test #%d.", i, test_num); + failure_mssg = msg; + } + i++; } } if (pass) { - /* Now load a large entry. This should result in the eviction - * of (VET,2), and the increase in the size of (VET, 0) from .25 - * VARIABLE_ENTRY_SIZE to .75 VARIABLE_ENTRY_SIZE. - * - * The following table illustrates the intended state of affairs - * after the eviction: - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 7.5 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB Y N 0 dirty (VET, 0) - * resize (VET, 0) to 10 KB - * move (VET, 0) to its alternate address - * - * (VET, 4) Y 10 KB N N - - - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - expected[0].size = 3 * VARIABLE_ENTRY_SIZE / 4; - expected[1].is_dirty = false; - expected[1].serialized = true; - expected[2].in_cache = false; - expected[2].destroyed = true; + if ((((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) == 0) && + ((cache_ptr->index_len != expected_index_len) || + (cache_ptr->index_size != expected_index_size))) || + (((flush_flags & H5C__FLUSH_INVALIDATE_FLAG) != 0) && + ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)))) { - num_large_entries = 2; + pass = false; + snprintf(msg, (size_t)128, "Unexpected cache len/size after flush in flush op test #%d.", + test_num); + failure_mssg = msg; + } + } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); + /* clean up the cache to prep for the next test */ + if (pass) { - if ((cache_ptr->index_len != 42) || - (cache_ptr->index_size != - (2 * 1024 * 1024) - (VARIABLE_ENTRY_SIZE) + (VARIABLE_ENTRY_SIZE / 2) + (LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * (3 * VARIABLE_ENTRY_SIZE / 4)) + (3 * VARIABLE_ENTRY_SIZE / 4) + - (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (2 * LARGE_ENTRY_SIZE)))) { - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 3."; + H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, "dummy mssg.") + + if (!pass) { + + snprintf(msg, (size_t)128, "Flush failed on cleanup in flush op test #%d.", test_num); + failure_mssg = msg; } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0) || + (cache_ptr->clean_index_size != 0) || (cache_ptr->dirty_index_size != 0)) { - /* verify entry status */ - verify_entry_status(cache_ptr, 1, (num_variable_entries + num_monster_entries + num_large_entries), - expected); + pass = false; + snprintf(msg, (size_t)128, "Unexpected cache len/size/cs/ds after cleanup in flush op test #%d.", + test_num); + failure_mssg = msg; + } } - if (pass) { + i = 0; + while (pass && (i < spec_size)) { - /* Now load another large entry. This should result in the eviction - * of (VET, 4), the increase in the size of (VET, 0) from .75 - * VARIABLE_ENTRY_SIZE to 1.0 VARIABLE_ENTRY_SIZE, and the renaming - * of (VET, 0) to its alternate address. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) - * resize (VET, 5) to 5 KB - * - * (VET, 6) Y 5 KB Y N - - - * - * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) - * - * (VET, 8) Y 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - expected[0].size = VARIABLE_ENTRY_SIZE; - expected[0].at_main_addr = false; - expected[3].is_dirty = false; - expected[3].serialized = true; - expected[4].in_cache = false; - expected[4].destroyed = true; + base_addr = entries[spec[i].entry_type]; + entry_ptr = &(base_addr[spec[i].entry_index]); - num_large_entries = 3; + entry_ptr->size = entry_sizes[spec[i].entry_type]; - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__DIRTIED_FLAG); + entry_ptr->deserialized = false; + entry_ptr->serialized = false; + entry_ptr->destroyed = false; - if ((cache_ptr->index_len != 42) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * VARIABLE_ENTRY_SIZE) + - (3 * VARIABLE_ENTRY_SIZE / 4) + (2 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != - ((3 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (3 * LARGE_ENTRY_SIZE)))) { + i++; + } + + i = 0; + while (pass && (i < check_size)) { + + base_addr = entries[check[i].entry_type]; + entry_ptr = &(base_addr[check[i].entry_index]); + + entry_ptr->size = entry_sizes[check[i].entry_type]; - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 4."; - } + entry_ptr->deserialized = false; + entry_ptr->serialized = false; + entry_ptr->destroyed = false; - /* verify entry status */ - verify_entry_status(cache_ptr, 2, (num_variable_entries + num_monster_entries + num_large_entries), - expected); + i++; } - if (pass) { +} /* check_flush_cache__flush_op_test() */ - /* load two more large entries. This should result in (VET, 5) being - * flushed, and increasing its size from 1/4 VARIABLE_ENTRY_SIZE to - * VARIABLE_ENTRY_SIZE. - * - * As a result of this size increase, the cache will have to look - * for another entry to evict. After flushing (VET, 6) and (VET, 7), - * it should evict (VET, 8), yielding the needed memory and dirtying - * (VET, 9). - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y Y - - - * - * (VET, 1) Y 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) Y 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) Y 5 KB N N 0, 9 - - * - * (VET, 6) Y 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ +/*------------------------------------------------------------------------- + * Function: check_flush_cache__flush_op_eviction_test() + * + * Purpose: Verify that flush operations work as expected when an + * entry is evicted. + * + * Do nothing if pass is false on entry. + * + * Return: void + * + *------------------------------------------------------------------------- + */ - expected[5].size = VARIABLE_ENTRY_SIZE / 2; - expected[5].is_dirty = false; - expected[5].serialized = true; - expected[6].is_dirty = false; - expected[6].serialized = true; - expected[7].is_dirty = false; - expected[7].serialized = true; - expected[8].in_cache = false; - expected[8].destroyed = true; - expected[9].is_dirty = true; +static void +check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) +{ + struct expected_entry_status *expected = NULL; + H5C_t *cache_ptr = file_ptr->shared->cache; + int i; + const int num_variable_entries = 10; + const int num_monster_entries = 31; + int num_large_entries = 14; + const int num_total_entries = num_variable_entries + num_monster_entries + num_large_entries; + test_entry_t *entry_ptr; + test_entry_t *base_addr; - num_large_entries = 5; + expected = malloc((size_t)num_total_entries * sizeof(struct expected_entry_status)); + if (expected == NULL) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); + pass = false; + failure_mssg = "couldn't allocate expected entry status array\n"; + } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 4); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 4, H5C__DIRTIED_FLAG); + if (expected) { + /* the expected array is used to maintain a table of the expected status of every + * entry used in this test. Note that since the function that processes this + * array only processes as much of it as it is told to, we don't have to + * worry about maintaining the status of entries that we haven't used yet. + */ + for (i = 0; i < num_variable_entries; i++) { + expected[i].entry_type = VARIABLE_ENTRY_TYPE; + expected[i].entry_index = (int)(i); + expected[i].size = VARIABLE_ENTRY_SIZE; + expected[i].in_cache = true; + expected[i].at_main_addr = true; + expected[i].is_dirty = true; + expected[i].is_protected = false; + expected[i].is_pinned = false; + expected[i].deserialized = true; + expected[i].serialized = false; + expected[i].destroyed = false; - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + - (4 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != - ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { + memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); + memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 5."; + expected[i].flush_dep_npar = 0; + expected[i].flush_dep_nchd = 0; + expected[i].flush_dep_ndirty_chd = 0; + expected[i].flush_order = -1; + expected[i].is_corked = false; } - /* verify entry status */ - verify_entry_status(cache_ptr, 3, (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } + /* NOTE: special cases for particular variable entries */ + expected[0].size = VARIABLE_ENTRY_SIZE / 4; + expected[0].is_pinned = true; - if (pass) { + expected[1].size = VARIABLE_ENTRY_SIZE / 4; - /* now touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to bring all the VARIABLE_ENTRY_TYPE entries to the - * end of the LRU list. - * - * Note that we don't have to worry about (VET, 0) and (VET, 9) - * as they are pinned and thus not in the LRU list to begin with. - */ - for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + expected[2].is_dirty = false; - for (i = 0; i < 5; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + expected[3].size = VARIABLE_ENTRY_SIZE / 4; - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + - (4 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != - ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { + expected[4].is_dirty = false; - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 6."; - } + expected[5].size = VARIABLE_ENTRY_SIZE / 4; - /* verify entry status */ - verify_entry_status(cache_ptr, 4, (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } + expected[6].size = VARIABLE_ENTRY_SIZE / 2; - if (pass) { + expected[7].size = VARIABLE_ENTRY_SIZE / 2; - /* Now load three more large entries. This should result - * in the evictions of (VET, 1), (VET, 3), and (VET, 5), and the - * unpinning of (VET, 0) - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) Y 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ + expected[8].is_dirty = false; - expected[0].is_pinned = false; - expected[1].in_cache = false; - expected[1].destroyed = true; - expected[3].in_cache = false; - expected[3].destroyed = true; - expected[5].in_cache = false; - expected[5].destroyed = true; + expected[9].is_dirty = false; + expected[9].is_pinned = true; - num_large_entries = 8; + for (; i < num_variable_entries + num_monster_entries; i++) { + expected[i].entry_type = MONSTER_ENTRY_TYPE; + expected[i].entry_index = (int)(i - num_variable_entries); + expected[i].size = MONSTER_ENTRY_SIZE; + expected[i].in_cache = true; + expected[i].at_main_addr = true; + expected[i].is_dirty = true; + expected[i].is_protected = false; + expected[i].is_pinned = false; + expected[i].deserialized = true; + expected[i].serialized = false; + expected[i].destroyed = false; - for (i = 5; i < 8; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); + memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); + + expected[i].flush_dep_npar = 0; + expected[i].flush_dep_nchd = 0; + expected[i].flush_dep_ndirty_chd = 0; + expected[i].flush_order = -1; + expected[i].is_corked = false; } - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + - (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + - (7 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (8 * LARGE_ENTRY_SIZE)))) { + for (; i < num_total_entries; i++) { + expected[i].entry_type = LARGE_ENTRY_TYPE; + expected[i].entry_index = (int)(i - num_monster_entries - num_variable_entries); + expected[i].size = LARGE_ENTRY_SIZE; + expected[i].in_cache = true; + expected[i].at_main_addr = true; + expected[i].is_dirty = true; + expected[i].is_protected = false; + expected[i].is_pinned = false; + expected[i].deserialized = true; + expected[i].serialized = false; + expected[i].destroyed = false; - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 7."; + memset(expected[i].flush_dep_par_type, 0, sizeof(expected[i].flush_dep_par_type)); + memset(expected[i].flush_dep_par_idx, 0, sizeof(expected[i].flush_dep_par_idx)); + + expected[i].flush_dep_npar = 0; + expected[i].flush_dep_nchd = 0; + expected[i].flush_dep_ndirty_chd = 0; + expected[i].flush_order = -1; + expected[i].is_corked = false; } - /* verify entry status */ - verify_entry_status(cache_ptr, 5, (num_variable_entries + num_monster_entries + num_large_entries), - expected); + assert(i == num_total_entries); + + pass = true; } if (pass) { - /* load another large entry. (VET, 6) should be evicted. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) Y 5 KB N N 9 - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB N Y - dirty (VET, 8) - * - * Start by updating the expected table for the expected changes in entry status: - */ - - expected[6].in_cache = false; - expected[6].destroyed = true; - - num_large_entries = 9; + if (cache_ptr == NULL) { - for (i = 8; i < 9; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + pass = false; + failure_mssg = "cache_ptr NULL on entry to flush ops test."; } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) - - (VARIABLE_ENTRY_SIZE / 2) + (8 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + - (31 * MONSTER_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)))) { + pass = false; + failure_mssg = "cache not empty at start of flush ops eviction test."; + } + else if ((cache_ptr->max_cache_size != (2 * 1024 * 1024)) || + (cache_ptr->min_clean_size != (1 * 1024 * 1024))) { pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 8."; + failure_mssg = "unexpected cache config at start of flush op eviction test."; } + else { - /* verify entry status */ - verify_entry_status(cache_ptr, 6, (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* set min clean size to zero for this test as it simplifies + * computing the expected cache size after each operation. + */ + + cache_ptr->min_clean_size = 0; + } } if (pass) { - /* Load another large entry. - * - * (VET, 7) should be evicted, and (VET, 9) should be unpinned. - * - * The following table shows the expected states of the variable - * size entries after the test. - * - * in - * entry: cache? size: dirty? pinned? pins: flush operations: - * - * (VET, 0) Y 10 KB Y N - - - * - * (VET, 1) N 2.5 KB N N - - - * - * (VET, 2) N 10 KB N N - - - * - * (VET, 3) N 2.5 KB N N - - - * - * (VET, 4) N 10 KB N N - - - * - * (VET, 5) N 5 KB N N - - - * - * (VET, 6) N 5 KB N N - - - * - * (VET, 7) N 5 KB N N - - - * - * (VET, 8) N 10 KB N N - - - * - * (VET, 9) Y 10 KB Y N - dirty (VET, 8) + /* the basic idea in this test is to insert a bunch of entries + * with flush operations associated with them, and then load + * other entries into the cache until the cache is full. At + * that point, load yet more entries into the cache, and see + * if the flush operations are performed as expected. * - * Start by updating the expected table for the expected changes in entry status: + * To make things a bit more interesting, we also include a + * couple of pins. */ - expected[7].in_cache = false; - expected[7].destroyed = true; - expected[9].is_pinned = false; + /* reset the stats before we start. If stats are enabled, we will + * check to see if they are as expected at the end. + */ + H5C_stats__reset(cache_ptr); - num_large_entries = 10; + /* load a few entries with pin relationships and flush ops. + * Start by just loading the entries. + */ - for (i = 9; i < 10; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, (VARIABLE_ENTRY_SIZE / 4), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 0, H5C__DIRTIED_FLAG); - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != - (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != - ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, (VARIABLE_ENTRY_SIZE / 4), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); - pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 9."; - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 2, H5C__NO_FLAGS_SET); - /* verify entry status */ - verify_entry_status(cache_ptr, 7, (num_variable_entries + num_monster_entries + num_large_entries), - expected); - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, (VARIABLE_ENTRY_SIZE / 4), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); - if (pass) { + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 4, H5C__NO_FLAGS_SET); - /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to bring all the VARIABLE_ENTRY_TYPE entries to the - * end of the LRU list. - * - * Both (VET, 0) and (VET, 7) have been unpinned, so they are - * now in the LRU list. - */ - for (i = 0; i < 31; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, (VARIABLE_ENTRY_SIZE / 4), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 5, H5C__DIRTIED_FLAG); - for (i = 0; i < 10; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, (VARIABLE_ENTRY_SIZE / 2), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 6, H5C__DIRTIED_FLAG); - /* verify cache size */ - if ((cache_ptr->index_len != 43) || - (cache_ptr->index_size != - (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7); + resize_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, (VARIABLE_ENTRY_SIZE / 2), true); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 7, H5C__DIRTIED_FLAG); + + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__NO_FLAGS_SET); + + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); + + if ((cache_ptr->index_len != 10) || (cache_ptr->index_size != - ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { + (4 * (VARIABLE_ENTRY_SIZE / 4)) + (2 * (VARIABLE_ENTRY_SIZE / 2)) + (4 * VARIABLE_ENTRY_SIZE))) { pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 10."; + failure_mssg = "unexpected size/len in flush op eviction test 1."; } - - /* verify entry status */ - verify_entry_status(cache_ptr, 8, (num_variable_entries + num_monster_entries + num_large_entries), - expected); } if (pass) { - /* load two more large entries. Things get a bit complicated here, - * so I'll go through the operation step by step. - * - * Initially, the cache has 4 KB of empty space, so the first entry - * (LET, 10) is loaded via calls to H5C_protect() H5C_unprotect() - * without causing any evictions. - * - * However, this is not the case for the call of H5C_protect() on - * (LET, 11). - * - * Before inserting (LET, 11), H5C_protect(LET, 11) must try to - * free up at least 4 KB of space. To do this, it starts scanning - * up the LRU list to find entries to evict. - * - * (VET, 0) is at the bottom of the LRU list, and thus is the first - * entry considered. However, it is dirty, so it flushed to disk, - * moved to the top of the LRU list, and marked clean. - * - * (VET, 9) is the next entry on the bottom of the LRU list. It is - * dirty too, calls its serialize callback function to construct an - * on disk image of the entry, and moves it to the top of the LRU - * list after the serialize callback returns. - * - * However, (VET 9)'s serialize function needs to modify (VET, 8), - * which is currently not in cache. Thus it calls H5C_protect(VET, 8) - * to gain access to it. H5C_protect(VET, 8) loads (VET, 8), and - * then attempts to evict entries to make space for it. - * - * However, H5C_make_space_in_cache() now exits without taking - * any action on re-entrant calls. Thus H5C_protect(VET, 8) simply - * loads the entry into the cache -- resulting in a cache that is - * 10 KB oversize. The subsequent unprotect puts (VET, 8) at the - * head of the LRU and marks it dirty. - * - * After (VET, 9) is serialized, it is flushed, and moved to the - * head of the LRU. - * - * At this point, the H5C_make_space_in_cache() call made by - * H5C_protect(LET, 11) now has 14 KB of space to make. - * - * The next entries on the LRU are (MET, 0) thru (MET, 30), - * (LET, 0) thru (LET, 10), and (VET, 8) -- all of which are dirty, - * and are therefore flushed and moved to the head of the LRU list. + /* Now set up the pinning relationships: * - * The next entry on the bottom of the LRU list is (VET, 0), which - * is clean, and is therefore evicted, leaving H5C_make_space_in_cache() - * with 4 KB of space to create. + * Briefly, (VET, 0) is pinned by (VET, 1), (VET, 3), and (VET, 5) + * (VET, 9) is pinned by (VET, 5), and (VET, 7) + */ + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 1, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 3, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 0); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 5, VARIABLE_ENTRY_TYPE, 9); + create_pinned_entry_dependency(file_ptr, VARIABLE_ENTRY_TYPE, 7, VARIABLE_ENTRY_TYPE, 9); + + /* Next, set up the flush operations: * - * This space is sufficient, so H5C_protect(VET, 8) inserts - * (VET, 8) into the cache's index, marks it as protected, and - * returns to the serialize function for (VET, 9). + * Briefly, (VET, 1) dirties (VET, 0) + * resizes (VET, 0) to 3/4 VARIABLE_ENTRY_SIZE * - * When the serialize function for (VET, 9) is done with (VET, 8), it - * calls H5C_unprotect(VET, 8), which marks (VET, 8) as dirty and - * unprotected, and places it at the head of the LRU. + * (VET, 3) dirties (VET, 0) + * resizes (VET, 0) to VARIABLE_ENTRY_SIZE + * moves (VET, 0) to its alternate address * - * (VET, 0) is the next item on the LRU -- it is clean and is therefore - * evicted -- leaving 6 KB of free space after (LET, 11) is inserted - * into the cache. + * (VET, 5) dirties (VET, 0) + * resizes itself to VARIABLE_ENTRY_SIZE / 2 * - * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then - * returns as well. + * (VET, 7) dirties (VET, 9) * - * The following table shows the expected states of the variable - * size entries after the test. + * (VET, 9) dirties (VET, 8) + */ + add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 1, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, true, + 3 * VARIABLE_ENTRY_SIZE / 4, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 0, true, + VARIABLE_ENTRY_SIZE, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 3, FLUSH_OP__MOVE, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 0, false, (size_t)0, NULL); + add_flush_op(VARIABLE_ENTRY_TYPE, 5, FLUSH_OP__RESIZE, VARIABLE_ENTRY_TYPE, 5, true, + VARIABLE_ENTRY_SIZE / 2, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 7, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 9, false, (size_t)0, NULL); + + add_flush_op(VARIABLE_ENTRY_TYPE, 9, FLUSH_OP__DIRTY, VARIABLE_ENTRY_TYPE, 8, false, (size_t)0, NULL); + } + + if (pass) { + + /* to summarize, at present the following variable size entries + * are in cache with the following characteristics: * * in * entry: cache? size: dirty? pinned? pins: flush operations: * - * (VET, 0) N 10 KB N N - - + * (VET, 0) Y 2.5 KB Y Y - - * - * (VET, 1) N 2.5 KB N N - - + * (VET, 1) Y 2.5 KB Y N 0 dirty (VET, 0), + * resize (VET, 0) to 7.5 KB * - * (VET, 2) N 10 KB N N - - + * (VET, 2) Y 10 KB N N - - * - * (VET, 3) N 2.5 KB N N - - * - * (VET, 4) N 10 KB N N - - + * (VET, 3) Y 2.5 KB N N 0 dirty (VET, 0) + * resize (VET, 0) to 10 KB + * move (VET, 0) to its alternate address * - * (VET, 5) N 5 KB N N - - + * (VET, 4) Y 10 KB N N - - * - * (VET, 6) N 5 KB N N - - * - * (VET, 7) N 5 KB N N - - + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB * - * (VET, 8) Y 10 KB N N - - + * (VET, 6) Y 5 KB Y N - - * - * (VET, 9) N 10 KB N N - - + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) * - * Start by updating the expected table for the expected changes in - * entry status: + * (VET, 8) Y 10 KB N N - - * - * Note that we reset the loaded, flushed, and destroyed - * fields of (VET,8) so we can track what is happening. + * (VET, 9) Y 10 KB N N - dirty (VET, 8) + * + * Recall that in this test bed, flush operations are executed the + * first time the associated entry is flushed, and are then + * deleted. */ - base_addr = entries[VARIABLE_ENTRY_TYPE]; - entry_ptr = &(base_addr[8]); - entry_ptr->deserialized = false; - entry_ptr->deserialized = false; - entry_ptr->destroyed = false; - - expected[0].in_cache = false; - expected[0].is_dirty = false; - expected[0].serialized = true; - expected[0].destroyed = true; - expected[8].in_cache = true; - expected[8].is_dirty = false; - expected[8].deserialized = true; - expected[8].serialized = true; - expected[8].destroyed = false; - expected[9].in_cache = false; - expected[9].is_dirty = false; - expected[9].serialized = true; - expected[9].destroyed = true; - - expected[10].in_cache = true; - expected[10].is_dirty = false; - expected[10].serialized = true; - expected[10].destroyed = false; - - num_large_entries = 12; - for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) { - expected[i].is_dirty = false; - expected[i].serialized = true; + /* Now fill up the cache with other, unrelated entries */ + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); } - for (i = 10; i < 12; i++) { + for (i = 0; i < 1; i++) { protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); } - /* verify cache size */ - if ((cache_ptr->index_len != 44) || - (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * 1024) - (1 * LARGE_ENTRY_SIZE)) || + /* The cache should now be exactly full */ + if ((cache_ptr->index_len != 42) || (cache_ptr->index_size != 2 * 1024 * 1024) || (cache_ptr->index_size != - ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { + ((4 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (4 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (1 * LARGE_ENTRY_SIZE)))) { pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 11."; + failure_mssg = "unexpected size/len in flush op eviction test 2."; } + else { - /* verify entry status */ - verify_entry_status(cache_ptr, 9, (num_variable_entries + num_monster_entries + num_large_entries), - expected); + /* verify the expected status of all entries we have loaded to date: */ + num_large_entries = 1; + verify_entry_status(cache_ptr, 0, + (num_variable_entries + num_monster_entries + num_large_entries), expected); + } } if (pass) { - /* protect and unprotect VET 9 to evict MET 0 */ - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); - - /* protect and unprotect VET 8 to dirty it and move it to the - * top of the LRU. Since we are dirtying it again, reset its - * serialized flag. - */ - base_addr = entries[VARIABLE_ENTRY_TYPE]; - entry_ptr = &(base_addr[8]); - entry_ptr->serialized = false; - - protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); - unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__DIRTIED_FLAG); - - /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the - * cache to evict VET 9 and move VET 8 to the bottom of the LRU. + /* Now load a large entry. This should result in the eviction + * of (VET,2), and the increase in the size of (VET, 0) from .25 + * VARIABLE_ENTRY_SIZE to .75 VARIABLE_ENTRY_SIZE. * - * Must do this twice to get the desired result. - */ - - /* skip MET 0 in first pass so that we evict VET 9 when we - * reload MET 0 + * The following table illustrates the intended state of affairs + * after the eviction: * - * Since we are reloading MET 0, reset its destroyed flag. - */ - base_addr = entries[MONSTER_ENTRY_TYPE]; - entry_ptr = &(base_addr[0]); - entry_ptr->destroyed = false; - - for (i = 1; i < num_monster_entries; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } - - for (i = 0; i < num_large_entries; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } - - for (i = 0; i < num_monster_entries; i++) { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } - - for (i = 0; i < num_large_entries; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } - - /* update the expected array to mark all these entries dirty again. */ - for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) { - expected[i].is_dirty = true; - } - - /* update MET 0 to set its in cache flag, and reset - * its destroyed flag + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 7.5 KB Y Y - - + * + * (VET, 1) Y 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) Y 2.5 KB Y N 0 dirty (VET, 0) + * resize (VET, 0) to 10 KB + * move (VET, 0) to its alternate address + * + * (VET, 4) Y 10 KB N N - - + * + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB + * + * (VET, 6) Y 5 KB Y N - - + * + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: */ - expected[10].in_cache = true; + expected[0].size = 3 * VARIABLE_ENTRY_SIZE / 4; + expected[1].is_dirty = false; + expected[1].serialized = true; + expected[2].in_cache = false; + expected[2].destroyed = true; - /* pass through non variable entries will flush VET 8, and evict VET 9. - * Update accordingly. - */ - expected[8].in_cache = true; - expected[8].is_dirty = true; - expected[8].serialized = false; - expected[8].destroyed = false; - expected[9].in_cache = false; - expected[9].is_dirty = false; - expected[9].serialized = true; - expected[9].destroyed = true; + num_large_entries = 2; - /* verify cache size */ - if ((cache_ptr->index_len != 44) || - (cache_ptr->index_size != - (2 * 1024 * 1024) - (5 * VARIABLE_ENTRY_SIZE) + (11 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != - ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, H5C__DIRTIED_FLAG); + if ((cache_ptr->index_len != 42) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (VARIABLE_ENTRY_SIZE) + (VARIABLE_ENTRY_SIZE / 2) + (LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * (3 * VARIABLE_ENTRY_SIZE / 4)) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (2 * LARGE_ENTRY_SIZE)))) { pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 12."; + failure_mssg = "unexpected size/len in flush op eviction test 3."; } - /* modifications to the H5C__flush_single_entry() function have - * changed the behavior of the cache slightly, causing - * this test to fail. Comment out for now -- come back and - * fix if all goes well. - */ - /* verify entry status */ - verify_entry_status(cache_ptr, 10, (num_variable_entries + num_monster_entries + num_large_entries), + verify_entry_status(cache_ptr, 1, (num_variable_entries + num_monster_entries + num_large_entries), expected); } if (pass) { - /* Load two more large entries. - * - * Since (VET, 8) is dirty, at first this will just cause (VET, 8) - * to be flushed. - * - * But all other entries in the cache are dirty, so the cache will - * flush them all, and then evict (VET, 8) on the second pass. + /* Now load another large entry. This should result in the eviction + * of (VET, 4), the increase in the size of (VET, 0) from .75 + * VARIABLE_ENTRY_SIZE to 1.0 VARIABLE_ENTRY_SIZE, and the renaming + * of (VET, 0) to its alternate address. * * The following table shows the expected states of the variable * size entries after the test. @@ -9338,947 +7970,872 @@ check_flush_cache__flush_op_eviction_test(H5F_t *file_ptr) * in * entry: cache? size: dirty? pinned? pins: flush operations: * - * (VET, 0) N 10 KB N N - - + * (VET, 0) Y 10 KB Y Y - - * - * (VET, 1) N 2.5 KB N N - - + * (VET, 1) Y 2.5 KB N N - - * * (VET, 2) N 10 KB N N - - * - * (VET, 3) N 2.5 KB N N - - + * (VET, 3) Y 2.5 KB N N - - * * (VET, 4) N 10 KB N N - - * - * (VET, 5) N 5 KB N N - - + * (VET, 5) Y 2.5 KB Y N 0, 9 dirty (VET, 0) + * resize (VET, 5) to 5 KB * - * (VET, 6) N 5 KB N N - - + * (VET, 6) Y 5 KB Y N - - * - * (VET, 7) N 5 KB N N - - + * (VET, 7) Y 5 KB Y N 9 dirty (VET, 9) * - * (VET, 8) N 10 KB N N - - + * (VET, 8) Y 10 KB N N - - * - * (VET, 9) N 10 KB N N - - + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) * - * Start by updating the expected table for the expected changes in - * entry status: + * Start by updating the expected table for the expected changes in entry status: */ + expected[0].size = VARIABLE_ENTRY_SIZE; + expected[0].at_main_addr = false; + expected[3].is_dirty = false; + expected[3].serialized = true; + expected[4].in_cache = false; + expected[4].destroyed = true; - expected[8].in_cache = false; - expected[8].is_dirty = false; - expected[8].serialized = true; - expected[8].destroyed = true; - - num_large_entries = 14; - - /* a newly loaded entry is not inserted in the cache until after - * space has been made for it. Thus (LET, 13) will not be flushed. - */ - for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; - i++) { - expected[i].is_dirty = false; - expected[i].serialized = true; - } + num_large_entries = 3; - for (i = 12; i < 14; i++) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); - } + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, H5C__DIRTIED_FLAG); - /* verify cache size */ - if ((cache_ptr->index_len != 45) || + if ((cache_ptr->index_len != 42) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * VARIABLE_ENTRY_SIZE) + + (3 * VARIABLE_ENTRY_SIZE / 4) + (2 * LARGE_ENTRY_SIZE)) || (cache_ptr->index_size != - (2 * 1024 * 1024) - (6 * VARIABLE_ENTRY_SIZE) + (13 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((31 * MONSTER_ENTRY_SIZE) + (14 * LARGE_ENTRY_SIZE)))) { + ((3 * VARIABLE_ENTRY_SIZE / 4) + (2 * VARIABLE_ENTRY_SIZE / 2) + (3 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (3 * LARGE_ENTRY_SIZE)))) { pass = false; - failure_mssg = "unexpected size/len in flush op eviction test 13."; + failure_mssg = "unexpected size/len in flush op eviction test 4."; } - /* modifications to the H5C__flush_single_entry() function have - * changed the behavior of the cache slightly, causing - * this test to fail. Comment out for now -- come back and - * fix if all goes well. - */ - /* verify entry status */ - verify_entry_status(cache_ptr, 11, (num_variable_entries + num_monster_entries + num_large_entries), + verify_entry_status(cache_ptr, 2, (num_variable_entries + num_monster_entries + num_large_entries), expected); } - /* at this point we have cycled all the variable size entries through - * the cache. - * - * flush the cache and end the test. - */ - - if (pass) { - - H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, - "Cache flush invalidate failed after flush op eviction test") - - if ((pass) && ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0))) { - - pass = false; - failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; - } - } - -#if H5C_COLLECT_CACHE_STATS - /* If we are collecting stats, check to see if we get the expected - * values. - * - * Testing the stats code is fairly new, but given the extent - * to which I find myself depending on the stats, I've decided - * to start testing the stats whenever it is convenient to do - * so. - */ - if (pass) { - - if ((cache_ptr->insertions[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 9) || - (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 12) || - (cache_ptr->take_ownerships[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[VARIABLE_ENTRY_TYPE] != 1) || - (cache_ptr->entry_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[VARIABLE_ENTRY_TYPE] != 2) || (cache_ptr->unpins[VARIABLE_ENTRY_TYPE] != 2) || - (cache_ptr->dirty_pins[VARIABLE_ENTRY_TYPE] != 2) || - (cache_ptr->pinned_flushes[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[VARIABLE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[VARIABLE_ENTRY_TYPE] != 3) || - (cache_ptr->size_decreases[VARIABLE_ENTRY_TYPE] != 6) || - (cache_ptr->entry_flush_size_changes[VARIABLE_ENTRY_TYPE] != 1) || - (cache_ptr->cache_flush_size_changes[VARIABLE_ENTRY_TYPE] != 0)) { - - pass = false; - failure_mssg = - "Unexpected variable size entry stats in check_flush_cache__flush_op_eviction_test()."; - } - } - - if (pass) { - - if ((cache_ptr->insertions[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->clears[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[LARGE_ENTRY_TYPE] != 25) || - (cache_ptr->evictions[LARGE_ENTRY_TYPE] != 14) || - (cache_ptr->take_ownerships[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pins[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->unpins[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[LARGE_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[LARGE_ENTRY_TYPE] != 0)) { - - pass = false; - failure_mssg = "Unexpected large entry stats in check_flush_cache__flush_op_eviction_test()."; - } - } - - if (pass) { - - if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 62) || - (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || - (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || - (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { - - pass = false; - failure_mssg = "Unexpected monster entry stats in check_flush_cache__flush_op_eviction_test()."; - } - } -#endif /* H5C_COLLECT_CACHE_STATS */ - if (pass) { - reset_entries(); - } - - free(expected); - -} /* check_flush_cache__flush_op_eviction_test() */ - -/*------------------------------------------------------------------------- - * Function: check_flush_cache__single_entry() - * - * Purpose: Verify that flush_cache behaves as expected when the cache - * contains only one element. - * - * Return: void - * - *------------------------------------------------------------------------- - */ - -static void -check_flush_cache__single_entry(H5F_t *file_ptr) -{ - H5C_t *cache_ptr = file_ptr->shared->cache; - - if (cache_ptr == NULL) { - - pass = false; - failure_mssg = "cache_ptr NULL on entry to single entry case."; - } - else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - - pass = false; - failure_mssg = "cache not empty at beginning of single entry case."; - } - - if (pass) { + /* load two more large entries. This should result in (VET, 5) being + * flushed, and increasing its size from 1/4 VARIABLE_ENTRY_SIZE to + * VARIABLE_ENTRY_SIZE. + * + * As a result of this size increase, the cache will have to look + * for another entry to evict. After flushing (VET, 6) and (VET, 7), + * it should evict (VET, 8), yielding the needed memory and dirtying + * (VET, 9). + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y Y - - + * + * (VET, 1) Y 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) Y 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) Y 5 KB N N 0, 9 - + * + * (VET, 6) Y 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 1, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + expected[5].size = VARIABLE_ENTRY_SIZE / 2; + expected[5].is_dirty = false; + expected[5].serialized = true; + expected[6].is_dirty = false; + expected[6].serialized = true; + expected[7].is_dirty = false; + expected[7].serialized = true; + expected[8].in_cache = false; + expected[8].destroyed = true; + expected[9].is_dirty = true; - if (pass) { + num_large_entries = 5; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 2, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ false); - } + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, H5C__DIRTIED_FLAG); - if (pass) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 4); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 4, H5C__DIRTIED_FLAG); - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 3, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (4 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 5."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 4, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); + /* verify entry status */ + verify_entry_status(cache_ptr, 3, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 5, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* now touch all the non VARIABLE_ENTRY_TYPE entries in the + * cache to bring all the VARIABLE_ENTRY_TYPE entries to the + * end of the LRU list. + * + * Note that we don't have to worry about (VET, 0) and (VET, 9) + * as they are pinned and thus not in the LRU list to begin with. + */ + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - if (pass) { + for (i = 0; i < 5; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 6, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (4 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (5 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 6."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 7, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); + /* verify entry status */ + verify_entry_status(cache_ptr, 4, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 8, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + /* Now load three more large entries. This should result + * in the evictions of (VET, 1), (VET, 3), and (VET, 5), and the + * unpinning of (VET, 0) + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) Y 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ - if (pass) { + expected[0].is_pinned = false; + expected[1].in_cache = false; + expected[1].destroyed = true; + expected[3].in_cache = false; + expected[3].destroyed = true; + expected[5].in_cache = false; + expected[5].destroyed = true; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 9, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + num_large_entries = 8; - if (pass) { + for (i = 5; i < 8; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 10, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + + (1 * VARIABLE_ENTRY_SIZE / 4) + (3 * VARIABLE_ENTRY_SIZE / 4) + + (7 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (8 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 7."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 11, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); + /* verify entry status */ + verify_entry_status(cache_ptr, 5, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 12, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + /* load another large entry. (VET, 6) should be evicted. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) Y 5 KB N N 9 - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB N Y - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ - if (pass) { + expected[6].in_cache = false; + expected[6].destroyed = true; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 13, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + num_large_entries = 9; - if (pass) { + for (i = 8; i < 9; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 14, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (3 * VARIABLE_ENTRY_SIZE) - + (VARIABLE_ENTRY_SIZE / 2) + (8 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE / 2) + (2 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 8."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 15, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); + /* verify entry status */ + verify_entry_status(cache_ptr, 6, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 16, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* Load another large entry. + * + * (VET, 7) should be evicted, and (VET, 9) should be unpinned. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) Y 10 KB Y N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) Y 10 KB Y N - dirty (VET, 8) + * + * Start by updating the expected table for the expected changes in entry status: + */ - if (pass) { + expected[7].in_cache = false; + expected[7].destroyed = true; + expected[9].is_pinned = false; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 17, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + num_large_entries = 10; - if (pass) { + for (i = 9; i < 10; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 18, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ false); - } + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 9."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 19, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); + /* verify entry status */ + verify_entry_status(cache_ptr, 7, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 20, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); + /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the + * cache to bring all the VARIABLE_ENTRY_TYPE entries to the + * end of the LRU list. + * + * Both (VET, 0) and (VET, 7) have been unpinned, so they are + * now in the LRU list. + */ + for (i = 0; i < 31; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } + + for (i = 0; i < 10; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } + + /* verify cache size */ + if ((cache_ptr->index_len != 43) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (4 * VARIABLE_ENTRY_SIZE) + (9 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((2 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (10 * LARGE_ENTRY_SIZE)))) { + + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 10."; + } + + /* verify entry status */ + verify_entry_status(cache_ptr, 8, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 21, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* load two more large entries. Things get a bit complicated here, + * so I'll go through the operation step by step. + * + * Initially, the cache has 4 KB of empty space, so the first entry + * (LET, 10) is loaded via calls to H5C_protect() H5C_unprotect() + * without causing any evictions. + * + * However, this is not the case for the call of H5C_protect() on + * (LET, 11). + * + * Before inserting (LET, 11), H5C_protect(LET, 11) must try to + * free up at least 4 KB of space. To do this, it starts scanning + * up the LRU list to find entries to evict. + * + * (VET, 0) is at the bottom of the LRU list, and thus is the first + * entry considered. However, it is dirty, so it flushed to disk, + * moved to the top of the LRU list, and marked clean. + * + * (VET, 9) is the next entry on the bottom of the LRU list. It is + * dirty too, calls its serialize callback function to construct an + * on disk image of the entry, and moves it to the top of the LRU + * list after the serialize callback returns. + * + * However, (VET 9)'s serialize function needs to modify (VET, 8), + * which is currently not in cache. Thus it calls H5C_protect(VET, 8) + * to gain access to it. H5C_protect(VET, 8) loads (VET, 8), and + * then attempts to evict entries to make space for it. + * + * However, H5C_make_space_in_cache() now exits without taking + * any action on re-entrant calls. Thus H5C_protect(VET, 8) simply + * loads the entry into the cache -- resulting in a cache that is + * 10 KB oversize. The subsequent unprotect puts (VET, 8) at the + * head of the LRU and marks it dirty. + * + * After (VET, 9) is serialized, it is flushed, and moved to the + * head of the LRU. + * + * At this point, the H5C_make_space_in_cache() call made by + * H5C_protect(LET, 11) now has 14 KB of space to make. + * + * The next entries on the LRU are (MET, 0) thru (MET, 30), + * (LET, 0) thru (LET, 10), and (VET, 8) -- all of which are dirty, + * and are therefore flushed and moved to the head of the LRU list. + * + * The next entry on the bottom of the LRU list is (VET, 0), which + * is clean, and is therefore evicted, leaving H5C_make_space_in_cache() + * with 4 KB of space to create. + * + * This space is sufficient, so H5C_protect(VET, 8) inserts + * (VET, 8) into the cache's index, marks it as protected, and + * returns to the serialize function for (VET, 9). + * + * When the serialize function for (VET, 9) is done with (VET, 8), it + * calls H5C_unprotect(VET, 8), which marks (VET, 8) as dirty and + * unprotected, and places it at the head of the LRU. + * + * (VET, 0) is the next item on the LRU -- it is clean and is therefore + * evicted -- leaving 6 KB of free space after (LET, 11) is inserted + * into the cache. + * + * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then + * returns as well. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) N 10 KB N N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) Y 10 KB N N - - + * + * (VET, 9) N 10 KB N N - - + * + * Start by updating the expected table for the expected changes in + * entry status: + * + * Note that we reset the loaded, flushed, and destroyed + * fields of (VET,8) so we can track what is happening. + */ + base_addr = entries[VARIABLE_ENTRY_TYPE]; + entry_ptr = &(base_addr[8]); + entry_ptr->deserialized = false; + entry_ptr->deserialized = false; + entry_ptr->destroyed = false; - if (pass) { + expected[0].in_cache = false; + expected[0].is_dirty = false; + expected[0].serialized = true; + expected[0].destroyed = true; + expected[8].in_cache = true; + expected[8].is_dirty = false; + expected[8].deserialized = true; + expected[8].serialized = true; + expected[8].destroyed = false; + expected[9].in_cache = false; + expected[9].is_dirty = false; + expected[9].serialized = true; + expected[9].destroyed = true; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 22, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } + expected[10].in_cache = true; + expected[10].is_dirty = false; + expected[10].serialized = true; + expected[10].destroyed = false; - if (pass) { + num_large_entries = 12; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 23, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { + expected[i].is_dirty = false; + expected[i].serialized = true; + } - if (pass) { + for (i = 10; i < 12; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 24, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ false); - } + /* verify cache size */ + if ((cache_ptr->index_len != 44) || + (cache_ptr->index_size != (2 * 1024 * 1024) - (2 * 1024) - (1 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 11."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 25, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); + /* verify entry status */ + verify_entry_status(cache_ptr, 9, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 26, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* protect and unprotect VET 9 to evict MET 0 */ + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 9, H5C__NO_FLAGS_SET); - if (pass) { + /* protect and unprotect VET 8 to dirty it and move it to the + * top of the LRU. Since we are dirtying it again, reset its + * serialized flag. + */ + base_addr = entries[VARIABLE_ENTRY_TYPE]; + entry_ptr = &(base_addr[8]); + entry_ptr->serialized = false; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 27, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + protect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__DIRTIED_FLAG); - if (pass) { + /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the + * cache to evict VET 9 and move VET 8 to the bottom of the LRU. + * + * Must do this twice to get the desired result. + */ - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 28, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + /* skip MET 0 in first pass so that we evict VET 9 when we + * reload MET 0 + * + * Since we are reloading MET 0, reset its destroyed flag. + */ + base_addr = entries[MONSTER_ENTRY_TYPE]; + entry_ptr = &(base_addr[0]); + entry_ptr->destroyed = false; - if (pass) { + for (i = 1; i < num_monster_entries; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 29, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + for (i = 0; i < num_large_entries; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - if (pass) { + for (i = 0; i < num_monster_entries; i++) { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 30, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } + for (i = 0; i < num_large_entries; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - if (pass) { + /* update the expected array to mark all these entries dirty again. */ + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { + expected[i].is_dirty = true; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 31, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* update MET 0 to set its in cache flag, and reset + * its destroyed flag + */ + expected[10].in_cache = true; - if (pass) { + /* pass through non variable entries will flush VET 8, and evict VET 9. + * Update accordingly. + */ + expected[8].in_cache = true; + expected[8].is_dirty = true; + expected[8].serialized = false; + expected[8].destroyed = false; + expected[9].in_cache = false; + expected[9].is_dirty = false; + expected[9].serialized = true; + expected[9].destroyed = true; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 32, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ false, - /* flags */ H5C__DIRTIED_FLAG | H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ true, - /* expected_serialized */ false, - /* expected_destroyed */ true); - } + /* verify cache size */ + if ((cache_ptr->index_len != 44) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (5 * VARIABLE_ENTRY_SIZE) + (11 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != + ((1 * VARIABLE_ENTRY_SIZE) + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { - if (pass) { + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 12."; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 33, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ false); + /* modifications to the H5C__flush_single_entry() function have + * changed the behavior of the cache slightly, causing + * this test to fail. Comment out for now -- come back and + * fix if all goes well. + */ + + /* verify entry status */ + verify_entry_status(cache_ptr, 10, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 34, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ false); - } + /* Load two more large entries. + * + * Since (VET, 8) is dirty, at first this will just cause (VET, 8) + * to be flushed. + * + * But all other entries in the cache are dirty, so the cache will + * flush them all, and then evict (VET, 8) on the second pass. + * + * The following table shows the expected states of the variable + * size entries after the test. + * + * in + * entry: cache? size: dirty? pinned? pins: flush operations: + * + * (VET, 0) N 10 KB N N - - + * + * (VET, 1) N 2.5 KB N N - - + * + * (VET, 2) N 10 KB N N - - + * + * (VET, 3) N 2.5 KB N N - - + * + * (VET, 4) N 10 KB N N - - + * + * (VET, 5) N 5 KB N N - - + * + * (VET, 6) N 5 KB N N - - + * + * (VET, 7) N 5 KB N N - - + * + * (VET, 8) N 10 KB N N - - + * + * (VET, 9) N 10 KB N N - - + * + * Start by updating the expected table for the expected changes in + * entry status: + */ - if (pass) { + expected[8].in_cache = false; + expected[8].is_dirty = false; + expected[8].serialized = true; + expected[8].destroyed = true; - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 35, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + num_large_entries = 14; - if (pass) { + /* a newly loaded entry is not inserted in the cache until after + * space has been made for it. Thus (LET, 13) will not be flushed. + */ + for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; + i++) { + expected[i].is_dirty = false; + expected[i].serialized = true; + } - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 36, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + for (i = 12; i < 14; i++) { + protect_entry(file_ptr, LARGE_ENTRY_TYPE, i); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, i, H5C__DIRTIED_FLAG); + } - if (pass) { + /* verify cache size */ + if ((cache_ptr->index_len != 45) || + (cache_ptr->index_size != + (2 * 1024 * 1024) - (6 * VARIABLE_ENTRY_SIZE) + (13 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((31 * MONSTER_ENTRY_SIZE) + (14 * LARGE_ENTRY_SIZE)))) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 37, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } + pass = false; + failure_mssg = "unexpected size/len in flush op eviction test 13."; + } - if (pass) { + /* modifications to the H5C__flush_single_entry() function have + * changed the behavior of the cache slightly, causing + * this test to fail. Comment out for now -- come back and + * fix if all goes well. + */ - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 38, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ true); + /* verify entry status */ + verify_entry_status(cache_ptr, 11, (num_variable_entries + num_monster_entries + num_large_entries), + expected); } + /* at this point we have cycled all the variable size entries through + * the cache. + * + * flush the cache and end the test. + */ + if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 39, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); - } + H5C_FLUSH_CACHE(file_ptr, H5C__FLUSH_INVALIDATE_FLAG, + "Cache flush invalidate failed after flush op eviction test") - if (pass) { + if ((pass) && ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0))) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 40, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); + pass = false; + failure_mssg = "Unexpected cache len/size after cleanup of flush op eviction test"; + } } +#if H5C_COLLECT_CACHE_STATS + /* If we are collecting stats, check to see if we get the expected + * values. + * + * Testing the stats code is fairly new, but given the extent + * to which I find myself depending on the stats, I've decided + * to start testing the stats whenever it is convenient to do + * so. + */ if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 41, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + if ((cache_ptr->insertions[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[VARIABLE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[VARIABLE_ENTRY_TYPE] != 9) || + (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 12) || + (cache_ptr->take_ownerships[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->moves[VARIABLE_ENTRY_TYPE] != 1) || + (cache_ptr->entry_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pins[VARIABLE_ENTRY_TYPE] != 2) || (cache_ptr->unpins[VARIABLE_ENTRY_TYPE] != 2) || + (cache_ptr->dirty_pins[VARIABLE_ENTRY_TYPE] != 2) || + (cache_ptr->pinned_flushes[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[VARIABLE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[VARIABLE_ENTRY_TYPE] != 3) || + (cache_ptr->size_decreases[VARIABLE_ENTRY_TYPE] != 6) || + (cache_ptr->entry_flush_size_changes[VARIABLE_ENTRY_TYPE] != 1) || + (cache_ptr->cache_flush_size_changes[VARIABLE_ENTRY_TYPE] != 0)) { + + pass = false; + failure_mssg = + "Unexpected variable size entry stats in check_flush_cache__flush_op_eviction_test()."; + } } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 42, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + if ((cache_ptr->insertions[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->clears[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->flushes[LARGE_ENTRY_TYPE] != 25) || + (cache_ptr->evictions[LARGE_ENTRY_TYPE] != 14) || + (cache_ptr->take_ownerships[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pins[LARGE_ENTRY_TYPE] != 0) || (cache_ptr->unpins[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[LARGE_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[LARGE_ENTRY_TYPE] != 0)) { + + pass = false; + failure_mssg = "Unexpected large entry stats in check_flush_cache__flush_op_eviction_test()."; + } } if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 43, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); + if ((cache_ptr->insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_insertions[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->clears[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->flushes[MONSTER_ENTRY_TYPE] != 62) || + (cache_ptr->evictions[MONSTER_ENTRY_TYPE] != 32) || + (cache_ptr->take_ownerships[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_moves[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pins[MONSTER_ENTRY_TYPE] != 0) || (cache_ptr->unpins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->dirty_pins[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_flushes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->pinned_clears[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_increases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->size_decreases[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->entry_flush_size_changes[MONSTER_ENTRY_TYPE] != 0) || + (cache_ptr->cache_flush_size_changes[MONSTER_ENTRY_TYPE] != 0)) { + + pass = false; + failure_mssg = "Unexpected monster entry stats in check_flush_cache__flush_op_eviction_test()."; + } } +#endif /* H5C_COLLECT_CACHE_STATS */ if (pass) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 44, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ false); + reset_entries(); } - if (pass) { + free(expected); - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 45, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } +} /* check_flush_cache__flush_op_eviction_test() */ - if (pass) { +/*------------------------------------------------------------------------- + * Function: check_flush_cache__single_entry() + * + * Purpose: Verify that flush_cache behaves as expected when the cache + * contains only one element. + * + * Return: void + * + *------------------------------------------------------------------------- + */ - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 46, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ true); - } +static void +check_flush_cache__single_entry(H5F_t *file_ptr) +{ + H5C_t *cache_ptr = file_ptr->shared->cache; - if (pass) { + if (cache_ptr == NULL) { - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 47, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + pass = false; + failure_mssg = "cache_ptr NULL on entry to single entry case."; } + else if ((cache_ptr->index_len != 0) || (cache_ptr->index_size != 0)) { - if (pass) { - - check_flush_cache__single_entry_test( - /* file_ptr */ file_ptr, - /* test_num */ 48, - /* entry_type */ PICO_ENTRY_TYPE, - /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__NO_FLAGS_SET, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + pass = false; + failure_mssg = "cache not empty at beginning of single entry case."; } if (pass) { check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 49, + /* test_num */ 1, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__NO_FLAGS_SET, /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ false, - /* expected_serialized */ true, + /* expected_deserialized */ true, + /* expected_serialized */ false, /* expected_destroyed */ false); } @@ -10286,13 +8843,13 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 50, + /* test_num */ 2, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__DIRTIED_FLAG, /* flush_flags */ H5C__NO_FLAGS_SET, - /* expected_deserialized */ false, + /* expected_deserialized */ true, /* expected_serialized */ true, /* expected_destroyed */ false); } @@ -10301,13 +8858,13 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 51, + /* test_num */ 3, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__NO_FLAGS_SET, /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, + /* expected_deserialized */ true, /* expected_serialized */ false, /* expected_destroyed */ false); } @@ -10316,13 +8873,13 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 52, + /* test_num */ 4, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__DIRTIED_FLAG, /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, - /* expected_deserialized */ false, + /* expected_deserialized */ true, /* expected_serialized */ false, /* expected_destroyed */ false); } @@ -10331,14 +8888,14 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 53, + /* test_num */ 5, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__NO_FLAGS_SET, /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, + /* expected_deserialized */ true, + /* expected_serialized */ false, /* expected_destroyed */ true); } @@ -10346,13 +8903,13 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 54, + /* test_num */ 6, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, + /* insert_flag */ false, + /* flags */ H5C__DIRTIED_FLAG, /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, - /* expected_deserialized */ false, + /* expected_deserialized */ true, /* expected_serialized */ true, /* expected_destroyed */ true); } @@ -10361,72 +8918,72 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 55, + /* test_num */ 7, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ false); + /* insert_flag */ false, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* expected_deserialized */ true, + /* expected_serialized */ false, + /* expected_destroyed */ true); } if (pass) { check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 56, + /* test_num */ 8, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, - /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG, - /* expected_deserialized */ false, - /* expected_serialized */ true, - /* expected_destroyed */ false); + /* insert_flag */ false, + /* flags */ H5C__DIRTIED_FLAG, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* expected_deserialized */ true, + /* expected_serialized */ false, + /* expected_destroyed */ true); } if (pass) { check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 57, + /* test_num */ 9, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + /* expected_serialized */ true, + /* expected_destroyed */ false); } if (pass) { check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 58, + /* test_num */ 10, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__NO_FLAGS_SET, /* expected_deserialized */ false, - /* expected_serialized */ false, - /* expected_destroyed */ true); + /* expected_serialized */ true, + /* expected_destroyed */ false); } if (pass) { check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 59, + /* test_num */ 11, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ false, /* expected_serialized */ false, /* expected_destroyed */ false); @@ -10436,12 +8993,12 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 60, + /* test_num */ 12, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ false, /* expected_serialized */ false, /* expected_destroyed */ false); @@ -10451,12 +9008,12 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 61, + /* test_num */ 13, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ false, /* expected_serialized */ true, /* expected_destroyed */ true); @@ -10466,12 +9023,12 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 62, + /* test_num */ 14, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_INVALIDATE_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG, /* expected_deserialized */ false, /* expected_serialized */ true, /* expected_destroyed */ true); @@ -10481,13 +9038,12 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 63, + /* test_num */ 15, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ false, /* expected_serialized */ false, /* expected_destroyed */ true); @@ -10497,13 +9053,12 @@ check_flush_cache__single_entry(H5F_t *file_ptr) check_flush_cache__single_entry_test( /* file_ptr */ file_ptr, - /* test_num */ 64, + /* test_num */ 16, /* entry_type */ PICO_ENTRY_TYPE, /* entry_idx */ 0, /* insert_flag */ true, - /* flags */ H5C__SET_FLUSH_MARKER_FLAG, - /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG | - H5C__FLUSH_MARKED_ENTRIES_FLAG, + /* flags */ H5C__NO_FLAGS_SET, + /* flush_flags */ H5C__FLUSH_INVALIDATE_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG, /* expected_deserialized */ false, /* expected_serialized */ false, /* expected_destroyed */ true); @@ -10523,13 +9078,9 @@ check_flush_cache__single_entry(H5F_t *file_ptr) * * 5) Marked dirty by call to H5C_mark_entry_dirty() while pinned or not. * - * 6) Entry marked for flush or not. - * - * 7) Call flush with H5C__FLUSH_MARKED_ENTRIES_FLAG or not. + * 6) Call flush with H5C__FLUSH_CLEAR_ONLY_FLAG or not. * - * 8) Call flush with H5C__FLUSH_CLEAR_ONLY_FLAG or not. - * - * This yields a total of 256 tests. + * This yields a total of 64 tests. * * The tests and their expected results are given in the spec table * below. The values assigned to the expected_serialized, @@ -10548,24 +9099,10 @@ check_flush_cache__single_entry(H5F_t *file_ptr) * was adapted from, and it doesn't do any particular harm. * * In general, we expect an entry to be flushed if it is dirty, and - * flush in invoked WITHOUT the H5C__FLUSH_CLEAR_ONLY_FLAG. However, - * there are exceptions: If flush is invoked with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG, only marked entries will be flushed. - * - * Further, unprotecting an entry with the H5C__SET_FLUSH_MARKER_FLAG - * will NOT mark the entry unless the entry has either been marked - * dirty either before or durting the unprotect call. This results in - * some counterintuitive entries in the table. It make be useful to - * look in the test code to see the exact order of operations. + * flush in invoked WITHOUT the H5C__FLUSH_CLEAR_ONLY_FLAG. * * Similarly, we expect an entry to be cleared if it is dirty, and - * flush is invoked WITH the H5C__FLUSH_CLEAR_ONLY_FLAG. Again, there - * are exceptions -- If flush is also invoked with the - * H5C__FLUSH_MARKED_ENTRIES_FLAG, only the marked entries will be - * cleared. - * - * The above comments about applying unprotect with the - * H5C__SET_FLUSH_MARKER_FLAG apply here as well. + * flush is invoked WITH the H5C__FLUSH_CLEAR_ONLY_FLAG. */ if (pass) { @@ -10573,14 +9110,14 @@ check_flush_cache__single_entry(H5F_t *file_ptr) struct pinned_single_entry_test_spec *spec = NULL; size_t i; - spec = malloc(256 * sizeof(struct pinned_single_entry_test_spec)); + spec = malloc(64 * sizeof(struct pinned_single_entry_test_spec)); if (spec == NULL) { pass = false; failure_mssg = "couldn't allocated pinned single entry test spec array"; } - for (i = 0; i < 256; i++) { + for (i = 0; i < 64; i++) { int test_num; int entry_type; int entry_idx; @@ -10605,32 +9142,20 @@ check_flush_cache__single_entry(H5F_t *file_ptr) pop_mark_dirty_pinned = (i / 2) % 2; unprotect_unpin = i % 2; - /* Generate alternating sequences of H5C__NO_FLAGS_SET - * and H5C__SET_FLUSH_MARKER_FLAG + /* Flags are not used for this test */ - if ((i / 32) % 2) - flags = H5C__SET_FLUSH_MARKER_FLAG; - else - flags = H5C__NO_FLAGS_SET; + flags = H5C__NO_FLAGS_SET; /* - * Generate sequences of H5C__NO_FLAGS_SET, - * H5C__FLUSH_MARKED_ENTRIES_FLAG, H5C__FLUSH_CLEAR_ONLY_FLAG - * and H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG + * Generate sequences of H5C__NO_FLAGS_SET, and H5C__FLUSH_CLEAR_ONLY_FLAG */ - switch (i / 64) { + switch (i / 32) { case 0: flush_flags = H5C__NO_FLAGS_SET; break; case 1: - flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG; - break; - case 2: flush_flags = H5C__FLUSH_CLEAR_ONLY_FLAG; break; - case 3: - flush_flags = H5C__FLUSH_MARKED_ENTRIES_FLAG | H5C__FLUSH_CLEAR_ONLY_FLAG; - break; default: flush_flags = H5C__NO_FLAGS_SET; break; @@ -10638,20 +9163,8 @@ check_flush_cache__single_entry(H5F_t *file_ptr) expected_serialized = false; if (0 == (flush_flags & H5C__FLUSH_CLEAR_ONLY_FLAG)) { - if (flush_flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) { - if (flags & H5C__SET_FLUSH_MARKER_FLAG) { - if (mark_dirty && pop_mark_dirty_prot) { - expected_serialized = true; - } - else if (dirty_flag || pop_mark_dirty_prot) { - expected_serialized = true; - } - } - } - else { - if (dirty_flag || mark_dirty || pop_mark_dirty_prot || pop_mark_dirty_pinned) - expected_serialized = true; - } + if (dirty_flag || mark_dirty || pop_mark_dirty_prot || pop_mark_dirty_pinned) + expected_serialized = true; } expected_destroyed = false; @@ -10673,7 +9186,7 @@ check_flush_cache__single_entry(H5F_t *file_ptr) } i = 0; - while (pass && (i < 256)) { + while (pass && (i < 64)) { check_flush_cache__pinned_single_entry_test( /* file_ptr */ file_ptr, /* test_num */ spec[i].test_num, @@ -13715,7 +12228,7 @@ check_flush_protected_err(unsigned paged) protect_entry(file_ptr, 0, 0); /* enable slist prior to flush */ - if ((pass) && (H5C_set_slist_enabled(cache_ptr, true, false) < 0)) { + if ((pass) && (H5C_set_slist_enabled(cache_ptr, true, true) < 0)) { pass = false; failure_mssg = "unable to enable slist prior to flush.\n"; diff --git a/test/cache_common.h b/test/cache_common.h index a9a8dbb..2e8a463 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -126,11 +126,6 @@ * for it to setup the slist on entry, and take it down * on exit. * - * Note that the slist need not be empty if the flags - * indicate a partial flush (i.e. - * H5C__FLUSH_MARKED_ENTRIES_FLAG). Compute clear_slist - * and pass it into H5C_set_slist_enabled as appropriate. - * * On error, set pass to false, and set failure_mssg * to the supplied error message. * @@ -140,12 +135,9 @@ #define H5C_FLUSH_CACHE(file, flags, fail_mssg) \ { \ - bool clear_slist; \ herr_t rslt; \ \ - clear_slist = ((flags & H5C__FLUSH_MARKED_ENTRIES_FLAG) != 0); \ - \ - rslt = H5C_set_slist_enabled((file)->shared->cache, true, false); \ + rslt = H5C_set_slist_enabled((file)->shared->cache, true, true); \ \ if (rslt >= 0) { \ \ @@ -154,7 +146,7 @@ \ if (rslt >= 0) { \ \ - rslt = H5C_set_slist_enabled((file)->shared->cache, false, clear_slist); \ + rslt = H5C_set_slist_enabled((file)->shared->cache, false, false); \ } \ \ if (rslt < 0) { \ diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 61b1dbe..9a86b8a 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -264,10 +264,7 @@ error: * * Purpose: Asserts that there is an entry in the specified cache with * the provided entry id and provided tag. The function will - * fail if this is not the case. If found, this function will - * set the entry's flush_marker flag, so future verification - * attempts can skip over this entry, knowing it has already been - * checked. + * fail if this is not the case. * * Return: 0 on Success, -1 on Failure * @@ -328,7 +325,7 @@ evict_entries(hid_t fid) mark_all_entries_investigated(fid); /* setup the skip list prior to calling H5C_flush_cache() */ - if (H5C_set_slist_enabled(f->shared->cache, true, false) < 0) + if (H5C_set_slist_enabled(f->shared->cache, true, true) < 0) TEST_ERROR; /* Evict all we can from the cache to examine full tag creation tree */ @@ -337,8 +334,8 @@ evict_entries(hid_t fid) */ H5C_flush_cache(f, H5C__FLUSH_INVALIDATE_FLAG); - /* shutdown the slist -- allow it to be non-empty */ - if (H5C_set_slist_enabled(f->shared->cache, false, true) < 0) + /* shutdown the slist */ + if (H5C_set_slist_enabled(f->shared->cache, false, false) < 0) TEST_ERROR; return 0; -- cgit v0.12