diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2017-03-13 14:45:42 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2017-03-13 14:45:42 (GMT) |
commit | 0b78740ff471ff6fe68ceae65e3df76fef886ec4 (patch) | |
tree | 5888190bb6dcad9da522c105a0d29c9d4b667778 | |
parent | c4a36e0bb3b56e0c8397876be1c66fedb2f57d83 (diff) | |
download | hdf5-0b78740ff471ff6fe68ceae65e3df76fef886ec4.zip hdf5-0b78740ff471ff6fe68ceae65e3df76fef886ec4.tar.gz hdf5-0b78740ff471ff6fe68ceae65e3df76fef886ec4.tar.bz2 |
Merge in reentrency changes to "make space in cache" from page_buffering branch.
-rw-r--r-- | src/H5C.c | 20 | ||||
-rw-r--r-- | src/H5Cpkg.h | 18 | ||||
-rw-r--r-- | test/cache.c | 97 | ||||
-rw-r--r-- | test/cache_image.c | 649 |
4 files changed, 733 insertions, 51 deletions
@@ -386,6 +386,7 @@ H5C_create(size_t max_cache_size, cache_ptr->cache_full = FALSE; cache_ptr->size_decreased = FALSE; cache_ptr->resize_in_progress = FALSE; + cache_ptr->msic_in_progress = FALSE; (cache_ptr->resize_ctl).version = H5C__CURR_AUTO_SIZE_CTL_VER; (cache_ptr->resize_ctl).rpt_fcn = NULL; @@ -6904,6 +6905,7 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, uint32_t entries_examined = 0; uint32_t initial_list_len; size_t empty_space; + hbool_t reentrant_call = FALSE; hbool_t prev_is_dirty = FALSE; hbool_t didnt_flush_entry = FALSE; hbool_t restart_scan; @@ -6921,6 +6923,18 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); HDassert(cache_ptr->index_size == (cache_ptr->clean_index_size + cache_ptr->dirty_index_size)); + /* check to see if cache_ptr->msic_in_progress is TRUE. If it, this + * is a re-entrant call via a client callback called in the make + * space in cache process. To avoid an infinite recursion, set + * reentrant_call to TRUE, and goto done. + */ + if(cache_ptr->msic_in_progress) { + reentrant_call = TRUE; + HGOTO_DONE(SUCCEED); + } /* end if */ + + cache_ptr->msic_in_progress = TRUE; + if ( write_permitted ) { restart_scan = FALSE; initial_list_len = cache_ptr->LRU_list_len; @@ -7180,6 +7194,12 @@ H5C__make_space_in_cache(H5F_t *f, hid_t dxpl_id, size_t space_needed, } done: + /* Sanity checks */ + HDassert(cache_ptr->msic_in_progress); + if(!reentrant_call) + cache_ptr->msic_in_progress = FALSE; + HDassert((!reentrant_call) || (cache_ptr->msic_in_progress)); + FUNC_LEAVE_NOAPI(ret_value) } /* H5C__make_space_in_cache() */ diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 3ea5144..321f1fb 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4104,6 +4104,23 @@ typedef struct H5C_tag_info_t { * of changes to the file driver info superblock extension * management code needed to support rings. * + * msic_in_progress: As the metadata cache has become re-entrant, and as + * the free space manager code has become more tightly + * integrated with the metadata cache, it is possible that + * a call to H5C_insert_entry() may trigger a call to + * H5C_make_space_in_cache(), which, via H5C__flush_single_entry() + * and client callbacks, may trigger an infinite regression + * of calls to H5C_make_space_in_cache(). + * + * The msic_in_progress boolean flag is used to detect this, + * and prevent the infinite regression that would otherwise + * occur. + * + * Note that this is issue is not hypothetical -- this field + * was added 2/16/17 to address this issue when it was + * exposed by modifications to test/fheap.c to cause it to + * use paged allocation. + * * resize_ctl: Instance of H5C_auto_size_ctl_t containing configuration * data for automatic cache resizing. * @@ -4743,6 +4760,7 @@ struct H5C_t { hbool_t cache_full; hbool_t size_decreased; hbool_t resize_in_progress; + hbool_t msic_in_progress; H5C_auto_size_ctl_t resize_ctl; /* Fields for epoch markers used in automatic cache size adjustment */ diff --git a/test/cache.c b/test/cache.c index ee4bff5..c381776 100644 --- a/test/cache.c +++ b/test/cache.c @@ -10369,14 +10369,28 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * 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. While (VET, 9) - * is still at the bottom of the LRU, it is marked flush in progress - * and this is skipped. Thus the next entries on the LRU are (MET, 0) - * thru (MET, 30) and (LET, 0) thru (LET, 10) -- all of which are dirty, + * 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 to make space for (VET, 8). + * 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). @@ -10385,22 +10399,10 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * calls H5C_unprotect(VET, 8), which markes (VET, 8) as dirty and * unprotected, and places it at the head of the LRU. * - * The serialize function for (VET, 9) then returns, and (VET, 9) is - * is written to disk, marked clean, and moved to 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. * - * At this point, the cache is still full (since (VET, 8) took the - * space created by the eviction of (VET, 0)). Thus - * H5C_protect(LET, 11) continues to look for space. While - * (MET, 0) was the next item on the LRU list when it called the - * serialize function for (VET, 9), the function notices that the - * LRU has been modified, and restarts its search for candidates - * for eviction at the bottom of the LRU. - * - * (MET, 0) is now at the bottom of the LRU, and is clean. Thus - * it is evicted. This makes sufficient space for (LET, 11), so - * H5C_protect(LET, 11) inserts it into the cache, marks it as - * protected, and returns. - * * H5C_unprotect(LET, 11) marks (LET, 11) as unprotected, and then * returns as well. * @@ -10426,9 +10428,9 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) * * (VET, 7) N 5 KB N N - - * - * (VET, 8) Y 10 KB Y N - - + * (VET, 8) Y 10 KB N N - - * - * (VET, 9) 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: @@ -10447,25 +10449,22 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) expected[0].serialized = TRUE; expected[0].destroyed = TRUE; expected[8].in_cache = TRUE; - expected[8].is_dirty = TRUE; + expected[8].is_dirty = FALSE; expected[8].deserialized = TRUE; - expected[8].serialized = FALSE; + expected[8].serialized = TRUE; expected[8].destroyed = FALSE; - expected[9].in_cache = TRUE; + expected[9].in_cache = FALSE; expected[9].is_dirty = FALSE; expected[9].serialized = TRUE; - expected[9].destroyed = FALSE; + expected[9].destroyed = TRUE; - expected[10].in_cache = FALSE; + expected[10].in_cache = TRUE; expected[10].is_dirty = FALSE; expected[10].serialized = TRUE; - expected[10].destroyed = TRUE; + expected[10].destroyed = FALSE; num_large_entries = 12; - /* a newly loaded entry is not inserted in the cache until after - * space has been made for it. Thus (LET, 11) will not be flushed. - */ for (i = num_variable_entries; i < num_variable_entries + num_monster_entries + num_large_entries - 1; i++) @@ -10483,10 +10482,10 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* verify cache size */ if((cache_ptr->index_len != 44) || (cache_ptr->index_size != (2 * 1024 * 1024) - - (2 * VARIABLE_ENTRY_SIZE) - - (10 * LARGE_ENTRY_SIZE)) || - (cache_ptr->index_size != ((2 * VARIABLE_ENTRY_SIZE) + - (30 * MONSTER_ENTRY_SIZE) + + (2 * 1024) - + (1 * LARGE_ENTRY_SIZE)) || + (cache_ptr->index_size != ((1 * VARIABLE_ENTRY_SIZE) + + (31 * MONSTER_ENTRY_SIZE) + (12 * LARGE_ENTRY_SIZE)))) { pass = FALSE; @@ -10496,15 +10495,27 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* verify entry status */ verify_entry_status(cache_ptr, 9, - (num_variable_entries + num_monster_entries + num_large_entries), + (num_variable_entries + num_monster_entries + + num_large_entries), expected); } if(pass) { - /* protect and unprotect VET 8 to move it to the top of the LRU */ + /* 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__NO_FLAGS_SET); + unprotect_entry(file_ptr, VARIABLE_ENTRY_TYPE, 8, H5C__DIRTIED_FLAG); /* Again, touch all the non VARIABLE_ENTRY_TYPE entries in the @@ -10516,7 +10527,13 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) /* 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; + for (i = 1; i < num_monster_entries; i++) { protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); @@ -10720,8 +10737,8 @@ check_flush_cache__flush_op_eviction_test(H5F_t * file_ptr) 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] != 8) || - (cache_ptr->evictions[VARIABLE_ENTRY_TYPE] != 11) || + (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) || diff --git a/test/cache_image.c b/test/cache_image.c index de0507b..0e7928a 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -4560,7 +4560,7 @@ cache_image_smoke_check_4(void) * If sufficient zoos have been created, continue to * 10). Otherwise goto 5) * - * 10) Open the file. + * 10) Open the file R/O. * * Verify that the file contains a metadata cache * image superblock extension message. @@ -4571,14 +4571,23 @@ cache_image_smoke_check_4(void) * * 13) Open the file. * - * Verify that the file doesn't contain a metadata cache + * Verify that the file contains a metadata cache * image superblock extension message. * * 14) Validate all the zoos. * * 15) Close the file. * - * 16) Delete the file. + * 16) Open the file. + * + * Verify that the file doesn't contain a metadata cache + * image superblock extension message. + * + * 17) Validate all the zoos. + * + * 18) Close the file. + * + * 19) Delete the file. * * Return: void * @@ -4821,9 +4830,56 @@ cache_image_smoke_check_5(void) } /* end while */ cp += 5; + /* 10) Open the file read only. + * + * Verify that the file contains a metadata cache image + * superblock extension message. + */ + if(pass) { + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ TRUE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ 0, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Validate all the zoos. */ + i = min_group; + while(pass && i <= max_group) { + sprintf(process_group_name, "/process_%d", i); + validate_zoo(file_id, process_group_name, i++); + } - - /* 10) Open the file. +#if H5C_COLLECT_CACHE_STATS + if( pass) { + if(cache_ptr->images_loaded == 0) { + pass = FALSE; + failure_mssg = "metadata cache image block not loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if(show_progress) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 12) Close the file. */ + if(pass) { + if(H5Fclose(file_id) < 0) { + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + /* 13) Open the file R/W. * * Verify that the file contains a metadata cache image * superblock extension message. @@ -4847,7 +4903,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 11) Validate all the zoos. */ + /* 14) Validate all the zoos. */ i = min_group; while ( ( pass ) && ( i <= max_group ) ) { @@ -4871,7 +4927,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 12) Close the file. */ + /* 15) Close the file. */ if ( pass ) { @@ -4883,7 +4939,7 @@ cache_image_smoke_check_5(void) } - /* 13) Open the file. + /* 16) Open the file. * * Verify that the file doesn't contain a metadata cache image * superblock extension message. @@ -4907,7 +4963,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 14) Validate all the zoos. + /* 17) Validate all the zoos. * * Verify that the metadata cache image superblock * extension message has been deleted. @@ -4935,7 +4991,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 15) Close the file. */ + /* 18) Close the file. */ if ( pass ) { @@ -4950,7 +5006,7 @@ cache_image_smoke_check_5(void) HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); - /* 16) Delete the file */ + /* 19) Delete the file */ if ( pass ) { @@ -6444,6 +6500,576 @@ cache_image_api_error_check_3(void) /*------------------------------------------------------------------------- + * Function: cache_image_api_error_check_4() + * + * Purpose: This test is one of a sequence of tests intended + * to verify correct management of API errors. + * + * The object of this test is to verify that a request for + * a cache image when a version 2 superblock is not available/ + * not requested is handled correctly. + * (the cache image request should be ignored silently). + * + * The test is set up as follows: + * + * 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + * + * 2) Create a HDF5 file using the above FAPL. + * + * 3) Create some datasets in the file. + * + * 4) Close the file. + * + * 5) Open the file read only. Verify that the file doesn't + * contain a cache image. + * + * 6) Verify that the datasets exist and contain the + * expected data + * + * Verify that the cache image was not loaded. + * + * 7) Close the file. + * + * 8) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 9) Close the file. + * + * 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + * + * 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + * + * 12) Create several more data sets. + * + * 13) Close the file. + * + * 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + * + * 15) Verify the data sets exist and contain the expected + * data. + * + * Verify that a cache image was not loaded. + * + * 16) Close the file. + * + * 17) Delete the file. + * + * Return: void + * + * Programmer: John Mainzer + * 9/25/15 + * + *------------------------------------------------------------------------- + */ + +static unsigned +cache_image_api_error_check_4(void) +{ + const char * fcn_name = "cache_image_api_error_check_4()"; + char filename[512]; + hbool_t show_progress = FALSE; + hid_t fapl_id = -1; + hid_t file_id = -1; + H5F_t *file_ptr = NULL; + H5C_t *cache_ptr = NULL; + int cp = 0; + H5AC_cache_image_config_t cache_image_config; + + TESTING("metadata cache image api error check 4"); + + pass = TRUE; + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* setup the file name */ + if ( pass ) { + + if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass = FALSE; + failure_mssg = "h5_fixname() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* 1) Create a FAPL requesting a cache image, but WITHOUT + * specifying the latest file format. + */ + if ( pass ) { + + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + + if ( fapl_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pcreate() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + /* set cache image config fields to taste */ + cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION; + cache_image_config.generate_image = TRUE; + cache_image_config.save_resize_status = FALSE; + cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE; + + if ( H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Pset_mdc_image_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 2) Create a HDF5 file using the above FAPL. */ + + if ( pass ) { + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fcreate() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 3) Create some datasets in the file. */ + + if ( pass ) { + + create_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + HDassert(cache_ptr); + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(1)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 4) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 5) Open the file read only. */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ TRUE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 6) Verify that the datasets exist and contain the + * expected data + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 7) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 8) Open the file R/W using the FAPL defined in 1) above. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 9) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + + /* 10) Open the file R/W using the FAPL defined in 1) above. + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + + if ( file_id < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fopen() failed.\n"; + + } else { + + file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE); + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "Can't get file_ptr."; + + } + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + /* get a pointer to the files internal data structure and then + * to the cache structure + */ + if ( pass ) { + + if ( file_ptr->shared->cache == NULL ) { + + pass = FALSE; + failure_mssg = "can't get cache pointer(1).\n"; + + } else { + + cache_ptr = file_ptr->shared->cache; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + if ( pass ) { + + if ( ( cache_ptr->load_image == TRUE ) || + ( cache_ptr->delete_image == TRUE ) ) { + + pass = FALSE; + failure_mssg = "mdci sb extension message present?\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 11) Verify that the data sets contain the expected data + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 5); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 12) Create several more data sets. */ + + if ( pass ) { + + create_datasets(file_id, 6, 10); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 13) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 14) Open the file read write. + * + * Verify that the file does not contain a cache image. + */ + + if ( pass ) { + + open_hdf5_file(/* create_file */ FALSE, + /* mdci_sbem_expected */ FALSE, + /* read_only */ FALSE, + /* set_mdci_fapl */ FALSE, + /* config_fsm */ FALSE, + /* hdf_file_name */ filename, + /* cache_image_flags */ H5C_CI__ALL_FLAGS, + /* file_id_ptr */ &file_id, + /* file_ptr_ptr */ &file_ptr, + /* cache_ptr_ptr */ &cache_ptr); + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 15) Verify the data sets exist and contain the expected data. + * + * Verify that a cache image was not loaded. + */ + + if ( pass ) { + + verify_datasets(file_id, 0, 10); + } + +#if H5C_COLLECT_CACHE_STATS + if ( pass ) { + + if ( cache_ptr->images_loaded != 0 ) { + + pass = FALSE; + failure_mssg = "metadata cache image block loaded(2)."; + } + } +#endif /* H5C_COLLECT_CACHE_STATS */ + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 16) Close the file. */ + + if ( pass ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass = FALSE; + failure_mssg = "H5Fclose() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* 17) Delete the file */ + + if ( pass ) { + + if ( HDremove(filename) < 0 ) { + + pass = FALSE; + failure_mssg = "HDremove() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass); + + + /* tidy up */ + if ( fapl_id != -1 ) + H5Pclose(fapl_id); + + + if ( pass ) { PASSED(); } else { H5_FAILED(); } + + if ( ! pass ) + HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n", + FUNC, failure_mssg); + + return !pass; + +} /* cache_image_api_error_check_4() */ +/*------------------------------------------------------------------------- * Function: main * * Purpose: Run tests on the cache code contained in H5C.c @@ -6489,6 +7115,7 @@ main(void) nerrs += cache_image_api_error_check_1(); nerrs += cache_image_api_error_check_2(); nerrs += cache_image_api_error_check_3(); + nerrs += cache_image_api_error_check_4(); return(nerrs > 0); |