From 90497050b818e914ab814e40811b1c0ff98384ea Mon Sep 17 00:00:00 2001 From: John Mainzer Date: Thu, 17 Jul 2008 00:12:36 -0500 Subject: [svn-r15382] Fix for bug in code to delete an entry from the cache while journaling, along with test code that uncovered the problem and associated additions & changes to the gziped test files in test/testfiles Tested serial on Phoenix and parallel on kagiso --- src/H5C2.c | 49 +- src/H5C2pkg.h | 5 +- test/cache2_common.c | 47 +- test/cache2_journal.c | 1628 +++++++++++++++++-------- test/testfiles/cache2_journal_sc01_000.jnl.gz | Bin 26904 -> 9610 bytes test/testfiles/cache2_journal_sc01_001.jnl.gz | Bin 24906 -> 9608 bytes test/testfiles/cache2_journal_sc01_002.jnl.gz | Bin 0 -> 9124 bytes test/testfiles/cache2_journal_sc01_003.jnl.gz | Bin 0 -> 27070 bytes test/testfiles/cache2_journal_sc01_004.jnl.gz | Bin 0 -> 25108 bytes test/testfiles/cache2_journal_sc02_000.jnl.gz | Bin 0 -> 13594 bytes test/testfiles/cache2_journal_sc02_001.jnl.gz | Bin 0 -> 24175 bytes test/testfiles/cache2_journal_sc02_002.jnl.gz | Bin 0 -> 24519 bytes test/testfiles/cache2_journal_sc02_003.jnl.gz | Bin 0 -> 103469 bytes test/testfiles/cache2_journal_sc02_004.jnl.gz | Bin 0 -> 100534 bytes 14 files changed, 1193 insertions(+), 536 deletions(-) create mode 100755 test/testfiles/cache2_journal_sc01_002.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc01_003.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc01_004.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc02_000.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc02_001.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc02_002.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc02_003.jnl.gz create mode 100755 test/testfiles/cache2_journal_sc02_004.jnl.gz diff --git a/src/H5C2.c b/src/H5C2.c index f261e08..1eb8ac6 100644 --- a/src/H5C2.c +++ b/src/H5C2.c @@ -5545,7 +5545,7 @@ H5C2_unprotect(H5F_t * f, HDassert( entry_ptr->is_read_only ); if ( dirtied ) { - + HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, \ "Read only entry modified(1)??") } @@ -5770,6 +5770,38 @@ H5C2_unprotect(H5F_t * f, "hash table contains multiple entries for addr?!?.") } + if ( cache_ptr->mdj_enabled ) { + + /* if journaling is enabled, we have a bit of house keeping + * to do before we delete the entry. + * + * First, if a transaction is in progress, it is possible + * that the target entry is on the transaction list. If it is + * it must be removed before the flush destroy. + * + * Second, if the target entry is on the journal write in + * in progress list, it must be removed from that list as + * well. + */ + + hbool_t entry_on_jwip_list = ( entry_ptr->last_trans != 0 ); + + if ( cache_ptr->trans_in_progress ) { + + H5C2__UPDATE_TL_FOR_ENTRY_CLEAR((cache_ptr), \ + (entry_ptr), \ + FAIL) + } + + if ( entry_on_jwip_list ) { + + entry_ptr->last_trans = 0; + H5C2__UPDATE_RP_FOR_JOURNAL_WRITE_COMPLETE((cache_ptr), \ + (entry_ptr), \ + FAIL) + } + } + if ( H5C2_flush_single_entry(f, dxpl_id, cache_ptr, @@ -5781,9 +5813,6 @@ H5C2_unprotect(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't flush.") } - - /* delete the entry from the transaction list if appropriate */ - H5C2__UPDATE_TL_FOR_ENTRY_CLEAR((cache_ptr), (entry_ptr), FAIL) } #ifdef H5_HAVE_PARALLEL else if ( clear_entry ) { @@ -5813,9 +5842,6 @@ H5C2_unprotect(H5F_t * f, HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "Can't clear.") } - - /* delete the entry from the transaction list if appropriate */ - H5C2__UPDATE_TL_FOR_ENTRY_CLEAR((cache_ptr), (entry_ptr), FAIL) } #endif /* H5_HAVE_PARALLEL */ } @@ -8107,7 +8133,7 @@ done: */ static herr_t -H5C2_flush_single_entry(const H5F_t * f, +H5C2_flush_single_entry(const H5F_t * f, hid_t dxpl_id, H5C2_t * cache_ptr, const H5C2_class_t * type_ptr, @@ -8139,9 +8165,11 @@ H5C2_flush_single_entry(const H5F_t * f, destroy = ( (flags & H5C2__FLUSH_INVALIDATE_FLAG) != 0 ); clear_only = ( (flags & H5C2__FLUSH_CLEAR_ONLY_FLAG) != 0); + /* attempt to find the target entry in the hash table */ H5C2__SEARCH_INDEX(cache_ptr, addr, entry_ptr, FAIL) + #if H5C2_DO_SANITY_CHECKS if ( entry_ptr != NULL ) { @@ -8180,6 +8208,7 @@ H5C2_flush_single_entry(const H5F_t * f, #endif #endif /* H5C2_DO_SANITY_CHECKS */ + if ( ( entry_ptr != NULL ) && ( entry_ptr->is_protected ) ) { @@ -8188,6 +8217,7 @@ H5C2_flush_single_entry(const H5F_t * f, "Attempt to flush a protected entry.") } + if ( ( entry_ptr != NULL ) && ( ( type_ptr == NULL ) || ( type_ptr->id == entry_ptr->type->id ) ) ) { @@ -8279,6 +8309,7 @@ H5C2_flush_single_entry(const H5F_t * f, } } + /* Update the replacement policy for the flush or eviction. */ if ( destroy ) { /* AKA eviction */ @@ -8733,6 +8764,7 @@ H5C2_flush_single_entry(const H5F_t * f, entry_ptr->is_dirty = FALSE; } + if ( destroy ) /* time to discard the entry */ { /* start by freeing the buffer for the on disk image */ @@ -8770,6 +8802,7 @@ H5C2_flush_single_entry(const H5F_t * f, entry_ptr->flush_in_progress = FALSE; } + if ( cache_ptr->log_flush ) { /* JRM */ /* may want to update this */ diff --git a/src/H5C2pkg.h b/src/H5C2pkg.h index 9c26409..52bcaf4 100644 --- a/src/H5C2pkg.h +++ b/src/H5C2pkg.h @@ -4443,8 +4443,7 @@ if ( cache_ptr->mdj_enabled ) \ * * If it is, see if the target entry is in the transaction * list. If it is, remove it from the list, and set its - * last_trans field to the current transaction number minus - * 1. + * last_trans field to zero. * * Return: N/A * @@ -4469,7 +4468,7 @@ if ( cache_ptr->mdj_enabled ) \ (cache_ptr->tl_tail_ptr), \ (cache_ptr->tl_len), \ (cache_ptr->tl_size), (fail_val)); \ - entry_ptr->last_trans = cache_ptr->trans_num - 1; \ + entry_ptr->last_trans = 0; \ } \ } /* H5C2__UPDATE_TL_FOR_ENTRY_CLEAR */ diff --git a/test/cache2_common.c b/test/cache2_common.c index ef8b396..c00d785 100644 --- a/test/cache2_common.c +++ b/test/cache2_common.c @@ -3199,7 +3199,7 @@ insert_entry2(H5F_t * file_ptr, pass2 = FALSE; failure_mssg2 = "error in H5C2_insert()."; -#if 1 /* This is useful debugging code. Lets keep it around. */ +#if 0 /* This is useful debugging code. Lets keep it around. */ HDfprintf(stdout, "result = %d\n", (int)result); HDfprintf(stdout, "entry_ptr->header.is_protected = %d\n", @@ -3522,7 +3522,7 @@ rename_entry2(H5C2_t * cache_ptr, ( ( ! ( entry_ptr->header.destroy_in_progress ) ) && ( entry_ptr->header.addr != new_addr ) ) ) { -#if 1 /* JRM */ +#if 0 /* JRM */ if ( result < 0 ) { HDfprintf(stdout, "%s: H5C2_rename_entry() failed.\n", fcn_name); @@ -3711,7 +3711,7 @@ protect_entry2(H5F_t * file_ptr, ( entry_ptr->size != entry_ptr->header.size ) || ( entry_ptr->addr != entry_ptr->header.addr ) ) { -#if 1 +#if 0 /* I've written the following debugging code several times * now. Lets keep it around so I don't have to write it * again. @@ -4029,6 +4029,26 @@ unprotect_entry2(H5F_t * file_ptr, pass2 = FALSE; failure_mssg2 = "error in H5C2_unprotect()."; + if ( verbose ) { + HDfprintf(stdout, "%s: error in H5C2_unprotect():\n", fcn_name); + + if ( result < 0 ) + HDfprintf(stdout, " result = %d.\n", (int)result); + + if ( ( entry_ptr->header.is_protected ) && + ( ( ! ( entry_ptr->is_read_only ) ) || + ( entry_ptr->ro_ref_count <= 0 ) ) ) + HDfprintf(stdout, " R/O sanity check failed.\n"); + + if ( entry_ptr->header.type != &(types2[type]) ) + HDfprintf(stdout, " Type mismatch.\n"); + + if ( entry_ptr->size != entry_ptr->header.size ) + HDfprintf(stdout, " size mismatch.\n"); + + if ( entry_ptr->addr != entry_ptr->header.addr ) + HDfprintf(stdout, " addr mismatch.\n"); + } } else { @@ -4036,16 +4056,26 @@ unprotect_entry2(H5F_t * file_ptr, entry_ptr->ro_ref_count--; + if ( verbose ) + HDfprintf(stdout, "%s: decremented ro ref count to %d.\n", + fcn_name, entry_ptr->ro_ref_count); + } else if ( entry_ptr->ro_ref_count == 1 ) { entry_ptr->is_protected = FALSE; entry_ptr->is_read_only = FALSE; entry_ptr->ro_ref_count = 0; + if ( verbose ) + HDfprintf(stdout, "%s: r/o unprotected.\n", fcn_name); + } else { entry_ptr->is_protected = FALSE; + if ( verbose ) + HDfprintf(stdout, "%s: r/w unprotected.\n", fcn_name); + } if ( pin_flag_set ) { @@ -4070,6 +4100,17 @@ unprotect_entry2(H5F_t * file_ptr, HDassert( entry_ptr->is_dirty ); } +#if 0 /* JRM */ + if ( entry_ptr->header.is_protected != entry_ptr->is_protected ) { + + HDfprintf(stdout, + "(%d, %d, %d): header.is_protected = %d != is_protected = %d.\n", + type, idx, entry_ptr->ro_ref_count, + (int)(entry_ptr->header.is_protected), + (int)(entry_ptr->is_protected)); + } +#endif /* JRM */ + HDassert( entry_ptr->header.is_protected == entry_ptr->is_protected ); HDassert( entry_ptr->header.is_read_only == entry_ptr->is_read_only ); HDassert( entry_ptr->header.ro_ref_count == entry_ptr->ro_ref_count ); diff --git a/test/cache2_journal.c b/test/cache2_journal.c index 9924bd5..1b24efc 100644 --- a/test/cache2_journal.c +++ b/test/cache2_journal.c @@ -89,8 +89,7 @@ static void jrnl_col_major_scan_forward2(H5F_t * file_ptr, hbool_t dirty_inserts, int dirty_unprotects, uint64_t trans_num); -#if 0 /* JRM */ -/* these functions are in-op at present */ + static void jrnl_row_major_scan_backward2(H5F_t * file_ptr, int32_t max_index, int32_t lag, @@ -124,7 +123,7 @@ static void jrnl_row_major_scan_forward2(H5F_t * file_ptr, int dirty_destroys, int dirty_unprotects, uint64_t trans_num); -#endif /* JRM */ + static void open_existing_file_for_journaling(const char * hdf_file_name, const char * journal_file_name, hid_t * file_id_ptr, @@ -201,6 +200,8 @@ static void mdj_smoke_check_00(void); static void mdj_smoke_check_01(void); +static void mdj_smoke_check_02(void); + static void write_verify_trans_num(H5C2_jbrb_t * struct_ptr, uint64_t trans_num, uint64_t verify_val); @@ -953,8 +954,6 @@ jrnl_col_major_scan_forward2(H5F_t * file_ptr, } /* jrnl_col_major_scan_forward2() */ -#if 0 /* JRM */ -/* this code commented out as it is in-op at present */ /*------------------------------------------------------------------------- * Function: jrnl_row_major_scan_backward2() @@ -1003,6 +1002,8 @@ jrnl_row_major_scan_backward2(H5F_t * file_ptr, int32_t type; int32_t idx; int32_t local_max_index; + int32_t lower_bound; + int32_t upper_bound; if ( verbose ) HDfprintf(stdout, "%s(): Entering.\n", fcn_name); @@ -1022,261 +1023,354 @@ jrnl_row_major_scan_backward2(H5F_t * file_ptr, idx = local_max_index + lag; + upper_bound = local_max_index; + lower_bound = upper_bound - 8; + while ( ( pass2 ) && ( idx >= -lag ) ) { - trans_num++; + if ( idx == ( upper_bound + lag ) ) { - begin_trans(cache_ptr, verbose, trans_num, - "jrnl_row_major_scan_backward inner loop"); - - if ( verbose ) { + trans_num++; + + begin_trans(cache_ptr, verbose, trans_num, + "jrnl_row_major_scan_backward inner loop"); - HDfprintf(stdout, "%lld:%d:%d: ", trans_num, type, idx); + if ( verbose ) + HDfprintf(stdout, "begin trans %lld.\n", + (long long)trans_num); + + if ( verbose ) + HDfprintf(stdout, "(%d, %d)\n", lower_bound, upper_bound); } + + while ( ( pass2 ) && ( idx >= lower_bound - lag ) ) + { + if ( verbose ) { + + HDfprintf(stdout, "%lld:%d:%d: ", trans_num, type, idx); + } - if ( ( pass2 ) && ( do_inserts ) && ( (idx - lag) >= 0 ) && - ( (idx - lag) <= local_max_index ) && - ( ((idx - lag) % 2) == 1 ) && - ( ! entry_in_cache2(cache_ptr, type, (idx - lag)) ) ) { + if ( ( pass2 ) && ( do_inserts ) && + ( (idx - lag) >= 0 ) && + ( (idx - lag) >= lower_bound ) && + ( (idx - lag) <= local_max_index ) && + ( (idx - lag) <= upper_bound ) && + ( ((idx - lag) % 2) == 1 ) && + ( ! entry_in_cache2(cache_ptr, type, (idx - lag)) ) ) { - if ( verbose ) - HDfprintf(stdout, "(i, %d, %d) ", type, (idx - lag)); + if ( verbose ) + HDfprintf(stdout, "(i, %d, %d) ", type, (idx - lag)); - insert_entry2(file_ptr, type, (idx - lag), dirty_inserts, - H5C2__NO_FLAGS_SET); - } + insert_entry2(file_ptr, type, (idx - lag), dirty_inserts, + H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( (idx - lag + 1) >= 0 ) && - ( (idx - lag + 1) <= local_max_index ) && - ( ( (idx - lag + 1) % 3 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 1) >= 0 ) && + ( (idx - lag + 1) >= lower_bound ) && + ( (idx - lag + 1) <= local_max_index ) && + ( (idx - lag + 1) <= upper_bound ) && + ( ( (idx - lag + 1) % 3 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p, %d, %d) ", type, (idx - lag + 1)); + if ( verbose ) + HDfprintf(stdout, "(p, %d, %d) ", + type, (idx - lag + 1)); - protect_entry2(file_ptr, type, (idx - lag + 1)); - } + protect_entry2(file_ptr, type, (idx - lag + 1)); + } - if ( ( pass2 ) && ( (idx - lag + 2) >= 0 ) && - ( (idx - lag + 2) <= local_max_index ) && - ( ( (idx - lag + 2) % 3 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 2) >= 0 ) && + ( (idx - lag + 2) >= lower_bound ) && + ( (idx - lag + 2) <= local_max_index ) && + ( (idx - lag + 2) <= upper_bound ) && + ( ( (idx - lag + 2) % 3 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag + 2)); + if ( verbose ) + HDfprintf(stdout, "(u, %d, %d) ", + type, (idx - lag + 2)); - unprotect_entry2(file_ptr, type, idx-lag+2, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } + unprotect_entry2(file_ptr, type, idx-lag+2, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( do_renames ) && ( (idx - lag + 2) >= 0 ) && - ( (idx - lag + 2) <= local_max_index ) && - ( ( (idx - lag + 2) % 3 ) == 0 ) ) { + if ( ( pass2 ) && ( do_renames ) && + ( (idx - lag + 2) >= 0 ) && + ( (idx - lag + 2) >= lower_bound ) && + ( (idx - lag + 2) <= local_max_index ) && + ( (idx - lag + 2) <= upper_bound ) && + ( ( (idx - lag + 2) % 3 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(r, %d, %d, %d) ", - type, (idx + lag + 2), (int)rename_to_main_addr); + if ( verbose ) + HDfprintf(stdout, "(r, %d, %d, %d) ", + type, (idx - lag + 2), + (int)rename_to_main_addr); - rename_entry2(cache_ptr, type, (idx - lag + 2), - rename_to_main_addr); - } + rename_entry2(cache_ptr, type, (idx - lag + 2), + rename_to_main_addr); + } - if ( ( pass2 ) && ( (idx - lag + 3) >= 0 ) && - ( (idx - lag + 3) <= local_max_index ) && - ( ( (idx - lag + 3) % 5 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 3) >= 0 ) && + ( (idx - lag + 3) >= lower_bound ) && + ( (idx - lag + 3) <= local_max_index ) && + ( (idx - lag + 3) <= upper_bound ) && + ( ( (idx - lag + 3) % 5 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p, %d, %d) ", type, (idx - lag + 3)); + if ( verbose ) + HDfprintf(stdout, "(p, %d, %d) ", + type, (idx - lag + 3)); - protect_entry2(file_ptr, type, (idx - lag + 3)); - } + protect_entry2(file_ptr, type, (idx - lag + 3)); + } - if ( ( pass2 ) && ( (idx - lag + 5) >= 0 ) && - ( (idx - lag + 5) <= local_max_index ) && - ( ( (idx - lag + 5) % 5 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 5) >= 0 ) && + ( (idx - lag + 5) >= lower_bound ) && + ( (idx - lag + 5) <= local_max_index ) && + ( (idx - lag + 5) <= upper_bound ) && + ( ( (idx - lag + 5) % 5 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag + 5)); + if ( verbose ) + HDfprintf(stdout, "(u, %d, %d) ", + type, (idx - lag + 5)); - unprotect_entry2(file_ptr, type, idx-lag+5, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } + unprotect_entry2(file_ptr, type, idx-lag+5, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( do_mult_ro_protects ) - { - if ( ( pass2 ) && ( (idx - lag + 5) >= 0 ) && - ( (idx - lag + 5) < local_max_index ) && - ( (idx - lag + 5) % 9 == 0 ) ) { + if ( do_mult_ro_protects ) + { + if ( ( pass2 ) && + ( (idx - lag + 5) >= 0 ) && + ( (idx - lag + 5) >= lower_bound ) && + ( (idx - lag + 5) < local_max_index ) && + ( (idx - lag + 5) < upper_bound ) && + ( (idx - lag + 5) % 9 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p-ro, %d, %d) ", type, - (idx - lag + 5)); + if ( verbose ) + HDfprintf(stdout, "(p-ro, %d, %d) ", type, + (idx - lag + 5)); - protect_entry_ro2(file_ptr, type, (idx - lag + 5)); - } + protect_entry_ro2(file_ptr, type, (idx - lag + 5)); + } - if ( ( pass2 ) && ( (idx - lag + 6) >= 0 ) && - ( (idx - lag + 6) < local_max_index ) && - ( (idx - lag + 6) % 11 == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 6) >= 0 ) && + ( (idx - lag + 6) >= lower_bound ) && + ( (idx - lag + 6) < local_max_index ) && + ( (idx - lag + 6) < upper_bound ) && + ( (idx - lag + 6) % 11 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p-ro, %d, %d) ", type, - (idx - lag + 6)); + if ( verbose ) + HDfprintf(stdout, "(p-ro, %d, %d) ", type, + (idx - lag + 6)); - protect_entry_ro2(file_ptr, type, (idx - lag + 6)); - } + protect_entry_ro2(file_ptr, type, (idx - lag + 6)); + } - if ( ( pass2 ) && ( (idx - lag + 7) >= 0 ) && - ( (idx - lag + 7) < local_max_index ) && - ( (idx - lag + 7) % 13 == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 7) >= 0 ) && + ( (idx - lag + 7) >= lower_bound ) && + ( (idx - lag + 7) < local_max_index ) && + ( (idx - lag + 7) < upper_bound ) && + ( (idx - lag + 7) % 13 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p-ro, %d, %d) ", type, - (idx - lag + 7)); + if ( verbose ) + HDfprintf(stdout, "(p-ro, %d, %d) ", type, + (idx - lag + 7)); - protect_entry_ro2(file_ptr, type, (idx - lag + 7)); - } + protect_entry_ro2(file_ptr, type, (idx - lag + 7)); + } - if ( ( pass2 ) && ( (idx - lag + 7) >= 0 ) && - ( (idx - lag + 7) < local_max_index ) && - ( (idx - lag + 7) % 9 == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 7) >= 0 ) && + ( (idx - lag + 7) >= lower_bound ) && + ( (idx - lag + 7) < local_max_index ) && + ( (idx - lag + 7) < upper_bound ) && + ( (idx - lag + 7) % 9 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u-ro, %d, %d) ", type, - (idx - lag + 7)); + if ( verbose ) + HDfprintf(stdout, "(u-ro, %d, %d) ", type, + (idx - lag + 7)); - unprotect_entry2(file_ptr, type, (idx - lag + 7), - FALSE, H5C2__NO_FLAGS_SET); - } + unprotect_entry2(file_ptr, type, (idx - lag + 7), + FALSE, H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( (idx - lag + 8) >= 0 ) && - ( (idx - lag + 8) < local_max_index ) && - ( (idx - lag + 8) % 11 == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 8) >= 0 ) && + ( (idx - lag + 8) >= lower_bound ) && + ( (idx - lag + 8) < local_max_index ) && + ( (idx - lag + 8) < upper_bound ) && + ( (idx - lag + 8) % 11 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u-ro, %d, %d) ", type, - (idx - lag + 8)); + if ( verbose ) + HDfprintf(stdout, "(u-ro, %d, %d) ", type, + (idx - lag + 8)); - unprotect_entry2(file_ptr, type, (idx - lag + 8), - FALSE, H5C2__NO_FLAGS_SET); - } + unprotect_entry2(file_ptr, type, (idx - lag + 8), + FALSE, H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( (idx - lag + 9) >= 0 ) && - ( (idx - lag + 9) < local_max_index ) && - ( (idx - lag + 9) % 13 == 0 ) ) { + if ( ( pass2 ) && + ( (idx - lag + 9) >= 0 ) && + ( (idx - lag + 9) >= lower_bound ) && + ( (idx - lag + 9) < local_max_index ) && + ( (idx - lag + 9) < upper_bound ) && + ( (idx - lag + 9) % 13 == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u-ro, %d, %d) ", type, - (idx - lag + 9)); + if ( verbose ) + HDfprintf(stdout, "(u-ro, %d, %d) ", type, + (idx - lag + 9)); - unprotect_entry2(file_ptr, type, (idx - lag + 9), - FALSE, H5C2__NO_FLAGS_SET); - } - } /* if ( do_mult_ro_protects ) */ + unprotect_entry2(file_ptr, type, (idx - lag + 9), + FALSE, H5C2__NO_FLAGS_SET); + } + } /* if ( do_mult_ro_protects ) */ - if ( ( pass2 ) && ( idx >= 0 ) && ( idx <= local_max_index ) ) { + if ( ( pass2 ) && + ( idx >= 0 ) && + ( idx >= lower_bound ) && + ( idx <= local_max_index ) && + ( idx <= upper_bound ) ) { - if ( verbose ) - HDfprintf(stdout, "(p, %d, %d) ", type, idx); + if ( verbose ) + HDfprintf(stdout, "(p, %d, %d) ", type, idx); - protect_entry2(file_ptr, type, idx); - } + protect_entry2(file_ptr, type, idx); + } - if ( ( pass2 ) && ( (idx + lag - 2) >= 0 ) && - ( (idx + lag - 2) <= local_max_index ) && - ( ( (idx + lag - 2) % 7 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx + lag - 2) >= 0 ) && + ( (idx + lag - 2) >= lower_bound ) && + ( (idx + lag - 2) <= local_max_index ) && + ( (idx + lag - 2) <= upper_bound ) && + ( ( (idx + lag - 2) % 7 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag - 2)); + if ( verbose ) + HDfprintf(stdout, "(u, %d, %d) ", + type, (idx + lag - 2)); - unprotect_entry2(file_ptr, type, idx+lag-2, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } + unprotect_entry2(file_ptr, type, idx+lag-2, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( (idx + lag - 1) >= 0 ) && - ( (idx + lag - 1) <= local_max_index ) && - ( ( (idx + lag - 1) % 7 ) == 0 ) ) { + if ( ( pass2 ) && + ( (idx + lag - 1) >= 0 ) && + ( (idx + lag - 1) >= lower_bound ) && + ( (idx + lag - 1) <= local_max_index ) && + ( (idx + lag - 1) <= upper_bound ) && + ( ( (idx + lag - 1) % 7 ) == 0 ) ) { - if ( verbose ) - HDfprintf(stdout, "(p, %d, %d) ", type, (idx + lag - 1)); + if ( verbose ) + HDfprintf(stdout, "(p, %d, %d) ", + type, (idx + lag - 1)); - protect_entry2(file_ptr, type, (idx + lag - 1)); - } + protect_entry2(file_ptr, type, (idx + lag - 1)); + } - if ( do_destroys ) { + if ( do_destroys ) { - if ( ( pass2 ) && ( (idx + lag) >= 0 ) && - ( ( idx + lag) <= local_max_index ) ) { + if ( ( pass2 ) && + ( (idx + lag) >= 0 ) && + ( (idx + lag) >= lower_bound ) && + ( ( idx + lag) <= local_max_index ) && + ( ( idx + lag) <= upper_bound ) ) { - switch ( (idx + lag) %4 ) { + switch ( (idx + lag) %4 ) { - case 0: - if ( (entries2[type])[idx+lag].is_dirty ) { + case 0: + if ( (entries2[type])[idx+lag].is_dirty ) { - unprotect_entry2(file_ptr, type, idx + lag, - NO_CHANGE, H5C2__NO_FLAGS_SET); - } else { + unprotect_entry2(file_ptr, type, idx + lag, + NO_CHANGE, + H5C2__NO_FLAGS_SET); + } else { + + unprotect_entry2(file_ptr, type, idx + lag, + dirty_unprotects, + H5C2__NO_FLAGS_SET); + } + break; + case 1: /* we just did an insert */ unprotect_entry2(file_ptr, type, idx + lag, - dirty_unprotects, - H5C2__NO_FLAGS_SET); - } - break; + NO_CHANGE, + H5C2__NO_FLAGS_SET); + break; - case 1: /* we just did an insert */ - unprotect_entry2(file_ptr, type, idx + lag, - NO_CHANGE, H5C2__NO_FLAGS_SET); - break; + case 2: + if ( (entries2[type])[idx + lag].is_dirty ) { - case 2: - if ( (entries2[type])[idx + lag].is_dirty ) { + unprotect_entry2(file_ptr, type, idx + lag, + NO_CHANGE, + H5C2__DELETED_FLAG); + } else { - unprotect_entry2(file_ptr, type, idx + lag, - NO_CHANGE, H5C2__DELETED_FLAG); - } else { + unprotect_entry2(file_ptr, type, idx + lag, + dirty_destroys, + H5C2__DELETED_FLAG); + } + break; + case 3: /* we just did an insrt */ unprotect_entry2(file_ptr, type, idx + lag, - dirty_destroys, - H5C2__DELETED_FLAG); - } - break; - - case 3: /* we just did an insrt */ - unprotect_entry2(file_ptr, type, idx + lag, - NO_CHANGE, H5C2__DELETED_FLAG); - break; - - default: - HDassert(0); /* this can't happen... */ - break; + NO_CHANGE, + H5C2__DELETED_FLAG); + break; + + default: + HDassert(0); /* this can't happen... */ + break; + } } - } - } else { + } else { - if ( ( pass2 ) && ( (idx + lag) >= 0 ) && - ( ( idx + lag) <= local_max_index ) ) { + if ( ( pass2 ) && + ( (idx + lag) >= 0 ) && + ( (idx + lag) >= lower_bound ) && + ( ( idx + lag) <= local_max_index ) && + ( ( idx + lag) <= upper_bound ) ) { - if ( verbose ) - HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag)); + if ( verbose ) + HDfprintf(stdout, + "(u, %d, %d) ", type, (idx + lag)); - unprotect_entry2(file_ptr, type, idx + lag, - dirty_unprotects, H5C2__NO_FLAGS_SET); + unprotect_entry2(file_ptr, type, idx + lag, + dirty_unprotects, + H5C2__NO_FLAGS_SET); + } } - } + + idx--; + + if ( verbose ) + HDfprintf(stdout, "\n"); + + } /* while ( ( pass2 ) && ( idx >= lower_bound - lag ) ) */ end_trans(file_ptr, cache_ptr, verbose, trans_num, "jrnl_row_major_scan_backward inner loop"); - if ( verbose ) - HDfprintf(stdout, "\n"); + if ( verbose ) + HDfprintf(stdout, "end trans %lld.\n", (long long)trans_num); + + upper_bound = lower_bound - (2 * lag) - 2; + lower_bound = upper_bound - 8; + + idx = upper_bound + lag; + + } /* while ( ( pass2 ) && ( idx >= -lag ) ) */ - idx--; - } type--; - } + + } /* while ( ( pass2 ) && ( type >= 0 ) ) */ if ( ( pass2 ) && ( display_stats ) ) { @@ -1287,10 +1381,6 @@ jrnl_row_major_scan_backward2(H5F_t * file_ptr, } /* jrnl_row_major_scan_backward2() */ -#endif /* JRM */ - -#if 0 /* JRM */ -/* this code commented out as it is in-op at present */ /*------------------------------------------------------------------------- * Function: jrnl_row_major_scan_forward2() @@ -1339,6 +1429,8 @@ jrnl_row_major_scan_forward2(H5F_t * file_ptr, int32_t type; int32_t idx; int32_t local_max_index; + int32_t lower_bound; + int32_t upper_bound; if ( verbose ) HDfprintf(stdout, "%s(): entering.\n", fcn_name); @@ -1358,291 +1450,401 @@ jrnl_row_major_scan_forward2(H5F_t * file_ptr, local_max_index = MIN(max_index, max_indices2[type]); + lower_bound = 0; + upper_bound = lower_bound + 8; + while ( ( pass2 ) && ( idx <= (local_max_index + lag) ) ) { - trans_num++; - - begin_trans(cache_ptr, verbose, trans_num, - "jrnl_row_major_scan_forward inner loop"); - - if ( verbose ) { - - HDfprintf(stdout, "%lld:%d:%d: ", trans_num, type, idx); - } + if ( idx == ( lower_bound - lag ) ) { - if ( ( pass2 ) && ( do_inserts ) && ( (idx + lag) >= 0 ) && - ( (idx + lag) <= local_max_index ) && - ( ((idx + lag) % 2) == 0 ) && - ( ! entry_in_cache2(cache_ptr, type, (idx + lag)) ) ) { + trans_num++; - if ( verbose ) - HDfprintf(stdout, "1(i, %d, %d) ", type, (idx + lag)); + begin_trans(cache_ptr, verbose, trans_num, + "jrnl_row_major_scan_forward inner loop"); - insert_entry2(file_ptr, type, (idx + lag), dirty_inserts, - H5C2__NO_FLAGS_SET); - } + if ( verbose ) + HDfprintf(stdout, "begin trans %lld.\n", + (long long)trans_num); + if ( verbose ) + HDfprintf(stdout, "(%d, %d)\n", lower_bound, upper_bound); + } - if ( ( pass2 ) && ( (idx + lag - 1) >= 0 ) && - ( (idx + lag - 1) <= local_max_index ) && - ( ( (idx + lag - 1) % 3 ) == 0 ) ) { + while ( ( pass2 ) && ( idx <= upper_bound + lag ) ) + { + + if ( verbose ) { - if ( verbose ) - HDfprintf(stdout, "2(p, %d, %d) ", type, (idx + lag - 1)); + HDfprintf(stdout, "%lld:%d:%d: ", trans_num, type, idx); + } - protect_entry2(file_ptr, type, (idx + lag - 1)); - } + if ( ( pass2 ) && ( do_inserts ) && + ( (idx + lag) >= 0 ) && + ( (idx + lag) >= lower_bound ) && + ( (idx + lag) <= local_max_index ) && + ( (idx + lag) <= upper_bound ) && + ( ((idx + lag) % 2) == 0 ) && + ( ! entry_in_cache2(cache_ptr, type, (idx + lag)) ) ) { - if ( ( pass2 ) && ( (idx + lag - 2) >= 0 ) && - ( (idx + lag - 2) <= local_max_index ) && - ( ( (idx + lag - 2) % 3 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "1(i, %d, %d) ", type, (idx + lag)); - if ( verbose ) - HDfprintf(stdout, "3(u, %d, %d) ", type, (idx + lag - 2)); + /*** insert entry idx + lag (if not already present *** */ + insert_entry2(file_ptr, type, (idx + lag), dirty_inserts, + H5C2__NO_FLAGS_SET); + } - unprotect_entry2(file_ptr, type, idx+lag-2, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } + if ( ( pass2 ) && + ( (idx + lag - 1) >= 0 ) && + ( (idx + lag - 1) >= lower_bound ) && + ( (idx + lag - 1) <= local_max_index ) && + ( (idx + lag - 1) <= upper_bound ) && + ( ( (idx + lag - 1) % 3 ) == 0 ) ) { - if ( ( pass2 ) && ( do_renames ) && ( (idx + lag - 2) >= 0 ) && - ( (idx + lag - 2) <= local_max_index ) && - ( ( (idx + lag - 2) % 3 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, + "2(p, %d, %d) ", type, (idx + lag - 1)); - if ( verbose ) - HDfprintf(stdout, "4(r, %d, %d, %d) ", - type, (idx + lag - 2), (int)rename_to_main_addr); + /*** protect entry idx + lag - 1 ***/ + protect_entry2(file_ptr, type, (idx + lag - 1)); + } - rename_entry2(cache_ptr, type, (idx + lag - 2), - rename_to_main_addr); - } + if ( ( pass2 ) && + ( (idx + lag - 2) >= 0 ) && + ( (idx + lag - 2) >= lower_bound ) && + ( (idx + lag - 2) <= local_max_index ) && + ( (idx + lag - 2) <= upper_bound ) && + ( ( (idx + lag - 2) % 3 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "3(u, %d, %d) ", + type, (idx + lag - 2)); - if ( ( pass2 ) && ( (idx + lag - 3) >= 0 ) && - ( (idx + lag - 3) <= local_max_index ) && - ( ( (idx + lag - 3) % 5 ) == 0 ) ) { + /*** unprotect entry idx + lag - 2 ***/ + unprotect_entry2(file_ptr, type, idx+lag-2, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( verbose ) - HDfprintf(stdout, "5(p, %d, %d) ", type, (idx + lag - 3)); - protect_entry2(file_ptr, type, (idx + lag - 3)); - } + if ( ( pass2 ) && ( do_renames ) && + ( (idx + lag - 2) >= 0 ) && + ( (idx + lag - 2) >= lower_bound ) && + ( (idx + lag - 2) <= local_max_index ) && + ( (idx + lag - 2) <= upper_bound ) && + ( ( (idx + lag - 2) % 3 ) == 0 ) ) { - if ( ( pass2 ) && ( (idx + lag - 5) >= 0 ) && - ( (idx + lag - 5) <= local_max_index ) && - ( ( (idx + lag - 5) % 5 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "4(r, %d, %d, %d) ", + type, (idx + lag - 2), + (int)rename_to_main_addr); - if ( verbose ) - HDfprintf(stdout, "6(u, %d, %d) ", type, (idx + lag - 5)); + /*** rename entry idx + lag -2 ***/ + rename_entry2(cache_ptr, type, (idx + lag - 2), + rename_to_main_addr); + } - unprotect_entry2(file_ptr, type, idx+lag-5, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } - if ( do_mult_ro_protects ) - { - if ( ( pass2 ) && ( (idx + lag - 5) >= 0 ) && - ( (idx + lag - 5) < local_max_index ) && - ( (idx + lag - 5) % 9 == 0 ) ) { + if ( ( pass2 ) && + ( (idx + lag - 3) >= 0 ) && + ( (idx + lag - 3) >= lower_bound ) && + ( (idx + lag - 3) <= local_max_index ) && + ( (idx + lag - 3) <= upper_bound ) && + ( ( (idx + lag - 3) % 5 ) == 0 ) ) { if ( verbose ) - HDfprintf(stdout, "7(p-ro, %d, %d) ", type, - (idx + lag - 5)); + HDfprintf(stdout, "5(p, %d, %d) ", + type, (idx + lag - 3)); - protect_entry_ro2(file_ptr, type, (idx + lag - 5)); - } + /*** protect entry idx + lag - 3 ***/ + protect_entry2(file_ptr, type, (idx + lag - 3)); + } - if ( ( pass2 ) && ( (idx + lag - 6) >= 0 ) && - ( (idx + lag - 6) < local_max_index ) && - ( (idx + lag - 6) % 11 == 0 ) ) { + if ( ( pass2 ) && + ( (idx + lag - 5) >= 0 ) && + ( (idx + lag - 5) >= lower_bound ) && + ( (idx + lag - 5) <= local_max_index ) && + ( (idx + lag - 5) <= upper_bound ) && + ( ( (idx + lag - 5) % 5 ) == 0 ) ) { if ( verbose ) - HDfprintf(stdout, "8(p-ro, %d, %d) ", type, - (idx + lag - 6)); + HDfprintf(stdout, "6(u, %d, %d) ", + type, (idx + lag - 5)); - protect_entry_ro2(file_ptr, type, (idx + lag - 6)); - } - if ( ( pass2 ) && ( (idx + lag - 7) >= 0 ) && - ( (idx + lag - 7) < local_max_index ) && - ( (idx + lag - 7) % 13 == 0 ) ) { + /*** unprotect entry idx + lag - 5 ***/ + unprotect_entry2(file_ptr, type, idx+lag-5, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( verbose ) - HDfprintf(stdout, "9(p-ro, %d, %d) ", type, - (idx + lag - 7)); + if ( do_mult_ro_protects ) + { + if ( ( pass2 ) && + ( (idx + lag - 5) >= 0 ) && + ( (idx + lag - 5) >= lower_bound ) && + ( (idx + lag - 5) < local_max_index ) && + ( (idx + lag - 5) < upper_bound ) && + ( (idx + lag - 5) % 9 == 0 ) ) { + + if ( verbose ) + HDfprintf(stdout, "7(p-ro, %d, %d) ", type, + (idx + lag - 5)); + + /*** protect ro entry idx + lag - 5 ***/ + protect_entry_ro2(file_ptr, type, (idx + lag - 5)); + } - protect_entry_ro2(file_ptr, type, (idx + lag - 7)); - } + if ( ( pass2 ) && + ( (idx + lag - 6) >= 0 ) && + ( (idx + lag - 6) >= lower_bound ) && + ( (idx + lag - 6) < local_max_index ) && + ( (idx + lag - 6) < upper_bound ) && + ( (idx + lag - 6) % 11 == 0 ) ) { - if ( ( pass2 ) && ( (idx + lag - 7) >= 0 ) && - ( (idx + lag - 7) < local_max_index ) && - ( (idx + lag - 7) % 9 == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "8(p-ro, %d, %d) ", type, + (idx + lag - 6)); - if ( verbose ) - HDfprintf(stdout, "10(u-ro, %d, %d) ", type, - (idx + lag - 7)); + /*** protect ro entry idx + lag - 6 ***/ + protect_entry_ro2(file_ptr, type, (idx + lag - 6)); + } - unprotect_entry2(file_ptr, type, (idx + lag - 7), - FALSE, H5C2__NO_FLAGS_SET); - } + if ( ( pass2 ) && + ( (idx + lag - 7) >= 0 ) && + ( (idx + lag - 7) >= lower_bound ) && + ( (idx + lag - 7) < local_max_index ) && + ( (idx + lag - 7) < upper_bound ) && + ( (idx + lag - 7) % 13 == 0 ) ) { - if ( ( pass2 ) && ( (idx + lag - 8) >= 0 ) && - ( (idx + lag - 8) < local_max_index ) && - ( (idx + lag - 8) % 11 == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "9(p-ro, %d, %d) ", type, + (idx + lag - 7)); - if ( verbose ) - HDfprintf(stdout, "11(u-ro, %d, %d) ", type, - (idx + lag - 8)); + /*** protect ro entry idx + lag - 7 ***/ + protect_entry_ro2(file_ptr, type, (idx + lag - 7)); + } - unprotect_entry2(file_ptr, type, (idx + lag - 8), - FALSE, H5C2__NO_FLAGS_SET); - } + if ( ( pass2 ) && + ( (idx + lag - 7) >= 0 ) && + ( (idx + lag - 7) >= lower_bound ) && + ( (idx + lag - 7) < local_max_index ) && + ( (idx + lag - 7) < upper_bound ) && + ( (idx + lag - 7) % 9 == 0 ) ) { - if ( ( pass2 ) && ( (idx + lag - 9) >= 0 ) && - ( (idx + lag - 9) < local_max_index ) && - ( (idx + lag - 9) % 13 == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "10(u-ro, %d, %d) ", type, + (idx + lag - 7)); - if ( verbose ) - HDfprintf(stdout, "12(u-ro, %d, %d) ", type, - (idx + lag - 9)); + /*** unprotect ro entry idx + lag - 7 ***/ + unprotect_entry2(file_ptr, type, (idx + lag - 7), + FALSE, H5C2__NO_FLAGS_SET); + } - unprotect_entry2(file_ptr, type, (idx + lag - 9), - FALSE, H5C2__NO_FLAGS_SET); - } - } /* if ( do_mult_ro_protects ) */ + if ( ( pass2 ) && + ( (idx + lag - 8) >= 0 ) && + ( (idx + lag - 8) >= lower_bound ) && + ( (idx + lag - 8) < local_max_index ) && + ( (idx + lag - 8) < upper_bound ) && + ( (idx + lag - 8) % 11 == 0 ) ) { - if ( ( pass2 ) && ( idx >= 0 ) && ( idx <= local_max_index ) ) { + if ( verbose ) + HDfprintf(stdout, "11(u-ro, %d, %d) ", type, + (idx + lag - 8)); - if ( verbose ) - HDfprintf(stdout, "13(p, %d, %d) ", type, idx); + /*** unprotect ro entry idx + lag - 8 ***/ + unprotect_entry2(file_ptr, type, (idx + lag - 8), + FALSE, H5C2__NO_FLAGS_SET); + } - protect_entry2(file_ptr, type, idx); - } + if ( ( pass2 ) && + ( (idx + lag - 9) >= 0 ) && + ( (idx + lag - 9) >= lower_bound ) && + ( (idx + lag - 9) < local_max_index ) && + ( (idx + lag - 9) < upper_bound ) && + ( (idx + lag - 9) % 13 == 0 ) ) { - if ( ( pass2 ) && ( (idx - lag + 2) >= 0 ) && - /*( (idx - lag + 2) <= max_indices2[type] ) && */ - ( (idx - lag + 2) <= local_max_index ) && - ( ( (idx - lag + 2) % 7 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "12(u-ro, %d, %d) ", type, + (idx + lag - 9)); - if ( verbose ) - HDfprintf(stdout, "14(u, %d, %d) ", type, (idx - lag + 2)); + /*** unprotect ro entry idx + lag - 9 ***/ + unprotect_entry2(file_ptr, type, (idx + lag - 9), + FALSE, H5C2__NO_FLAGS_SET); + } + } /* if ( do_mult_ro_protects ) */ - unprotect_entry2(file_ptr, type, idx-lag+2, NO_CHANGE, - H5C2__NO_FLAGS_SET); - } + if ( ( pass2 ) && + ( idx >= 0 ) && + ( idx >= lower_bound ) && + ( idx <= local_max_index ) && + ( idx <= upper_bound ) ) { - if ( ( pass2 ) && ( (idx - lag + 1) >= 0 ) && - /*( (idx - lag + 1) <= max_indices2[type] ) && */ - ( (idx - lag + 1) <= local_max_index ) && - ( ( (idx - lag + 1) % 7 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "13(p, %d, %d) ", type, idx); - if ( verbose ) - HDfprintf(stdout, "15(p, %d, %d) ", type, (idx - lag + 1)); + /*** protect entry idx ***/ + protect_entry2(file_ptr, type, idx); + } - protect_entry2(file_ptr, type, (idx - lag + 1)); - } + if ( ( pass2 ) && + ( (idx - lag + 2) >= 0 ) && + ( (idx - lag + 2) >= lower_bound ) && + ( (idx - lag + 2) <= local_max_index ) && + ( (idx - lag + 2) <= upper_bound ) && + ( ( (idx - lag + 2) % 7 ) == 0 ) ) { + if ( verbose ) + HDfprintf(stdout, "14(u, %d, %d) ", + type, (idx - lag + 2)); - if ( do_destroys ) { + /*** unprotect entry idx - lag + 2 ***/ + unprotect_entry2(file_ptr, type, idx-lag+2, NO_CHANGE, + H5C2__NO_FLAGS_SET); + } - if ( ( pass2 ) && ( (idx - lag) >= 0 ) && - ( ( idx - lag) <= local_max_index ) ) { + if ( ( pass2 ) && + ( (idx - lag + 1) >= 0 ) && + ( (idx - lag + 1) >= lower_bound ) && + ( (idx - lag + 1) <= local_max_index ) && + ( (idx - lag + 1) <= upper_bound ) && + ( ( (idx - lag + 1) % 7 ) == 0 ) ) { - switch ( (idx - lag) %4 ) { + if ( verbose ) + HDfprintf(stdout, "15(p, %d, %d) ", + type, (idx - lag + 1)); - case 0: /* we just did an insert */ + /*** protect entry idx - lag + 1 ***/ + protect_entry2(file_ptr, type, (idx - lag + 1)); + } - if ( verbose ) - HDfprintf(stdout, - "16(u, %d, %d) ", type, (idx - lag)); - unprotect_entry2(file_ptr, type, idx - lag, - NO_CHANGE, H5C2__NO_FLAGS_SET); - break; + if ( do_destroys ) { - case 1: - if ( (entries2[type])[idx-lag].is_dirty ) { + if ( ( pass2 ) && + ( (idx - lag) >= 0 ) && + ( (idx - lag) >= lower_bound ) && + ( ( idx - lag) <= local_max_index ) && + ( ( idx - lag) <= upper_bound ) ) { - if ( verbose ) - HDfprintf(stdout, - "17(u, %d, %d) ", type, (idx - lag)); + switch ( (idx - lag) %4 ) { - unprotect_entry2(file_ptr, type, idx - lag, - NO_CHANGE, H5C2__NO_FLAGS_SET); - } else { + case 0: /* we just did an insert */ - if ( verbose ) - HDfprintf(stdout, - "18(u, %d, %d) ", type, (idx - lag)); + if ( verbose ) + HDfprintf(stdout, "16(u, %d, %d) ", + type, (idx - lag)); + /*** unprotect entry NC idx - lag ***/ unprotect_entry2(file_ptr, type, idx - lag, - dirty_unprotects, - H5C2__NO_FLAGS_SET); - } - break; + NO_CHANGE, H5C2__NO_FLAGS_SET); + break; - case 2: /* we just did an insrt */ + case 1: + if ( (entries2[type])[idx-lag].is_dirty ) { - if ( verbose ) - HDfprintf(stdout, - "19(u-del, %d, %d) ", type, (idx - lag)); + if ( verbose ) + HDfprintf(stdout, "17(u, %d, %d) ", + type, (idx - lag)); - unprotect_entry2(file_ptr, type, idx - lag, - NO_CHANGE, H5C2__DELETED_FLAG); - break; + /*** unprotect entry NC idx - lag ***/ + unprotect_entry2(file_ptr, type, idx - lag, + NO_CHANGE, + H5C2__NO_FLAGS_SET); + } else { - case 3: - if ( (entries2[type])[idx-lag].is_dirty ) { + if ( verbose ) + HDfprintf(stdout, "18(u, %d, %d) ", + type, (idx - lag)); - if ( verbose ) - HDfprintf(stdout, - "20(u-del, %d, %d) ", - type, (idx - lag)); + /*** unprotect entry idx - lag ***/ + unprotect_entry2(file_ptr, type, idx - lag, + dirty_unprotects, + H5C2__NO_FLAGS_SET); + } + break; - unprotect_entry2(file_ptr, type, idx - lag, - NO_CHANGE, H5C2__DELETED_FLAG); - } else { + case 2: /* we just did an insrt */ if ( verbose ) - HDfprintf(stdout, - "21(u-del, %d, %d) ", + HDfprintf(stdout, "19(u-del, %d, %d) ", type, (idx - lag)); + /*** unprotect delete idx - lag ***/ unprotect_entry2(file_ptr, type, idx - lag, - dirty_destroys, - H5C2__DELETED_FLAG); - } - break; - - default: - HDassert(0); /* this can't happen... */ - break; + NO_CHANGE, H5C2__DELETED_FLAG); + break; + + case 3: + if ( (entries2[type])[idx-lag].is_dirty ) { + + if ( verbose ) + HDfprintf(stdout, "20(u-del, %d, %d) ", + type, (idx - lag)); + + /*** unprotect delete idx - lag ***/ + unprotect_entry2(file_ptr, type, idx - lag, + NO_CHANGE, + H5C2__DELETED_FLAG); + } else { + + if ( verbose ) + HDfprintf(stdout, "21(u-del, %d, %d) ", + type, (idx - lag)); + + /*** unprotect delete idx - lag ***/ + unprotect_entry2(file_ptr, type, idx - lag, + dirty_destroys, + H5C2__DELETED_FLAG); + } + break; + + default: + HDassert(0); /* this can't happen... */ + break; + } } - } - } else { + } else { - if ( ( pass2 ) && ( (idx - lag) >= 0 ) && - ( ( idx - lag) <= local_max_index ) ) { + if ( ( pass2 ) && + ( (idx - lag) >= 0 ) && + ( (idx - lag) >= lower_bound ) && + ( ( idx - lag) <= local_max_index ) && + ( ( idx - lag) <= upper_bound ) ) { - if ( verbose ) - HDfprintf(stdout, "22(u, %d, %d) ", type, (idx - lag)); + if ( verbose ) + HDfprintf(stdout, "22(u, %d, %d) ", + type, (idx - lag)); - unprotect_entry2(file_ptr, type, idx - lag, - dirty_unprotects, H5C2__NO_FLAGS_SET); + /*** unprotect idx - lag ***/ + unprotect_entry2(file_ptr, type, idx - lag, + dirty_unprotects, H5C2__NO_FLAGS_SET); + } } - } + + idx++; + + if ( verbose ) + HDfprintf(stdout, "\n"); + + } /* while ( ( pass2 ) && ( idx <= upper_bound ) ) */ end_trans(file_ptr, cache_ptr, verbose, trans_num, "jrnl_row_major_scan_forward inner loop"); - if ( verbose ) - HDfprintf(stdout, "\n"); + if ( verbose ) + HDfprintf(stdout, "end trans %lld.\n", (long long)trans_num); + + lower_bound = upper_bound + (2 * lag) + 2; + upper_bound = lower_bound + 8; + + idx = lower_bound - lag; + + } /* while ( ( pass2 ) && ( idx <= (local_max_index + lag) ) ) */ - idx++; - } type++; - } + + } /* while ( ( pass2 ) && ( type < NUMBER_OF_ENTRY_TYPES ) ) */ if ( ( pass2 ) && ( display_stats ) ) { @@ -1653,8 +1855,6 @@ jrnl_row_major_scan_forward2(H5F_t * file_ptr, } /* jrnl_row_major_scan_forward2() */ -#endif /* JRM */ - /*------------------------------------------------------------------------- * Function: open_existing_file_for_journaling() @@ -3986,137 +4186,510 @@ mdj_smoke_check_00(void) } } - if ( show_progress ) - HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /* b) Verify that the journal file has been deleted. */ + verify_journal_deleted(journal_filename); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /************************************************************/ + /* 5) Re-open the file with journaling disabled. Do a */ + /* transaction or two, and verify that the transactions */ + /* took place, and that there is no journal file. */ + /************************************************************/ + + /* re-open the file without journaling enabled */ + + open_existing_file_without_journaling(filename, &file_id, + &file_ptr, &cache_ptr); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /* do a transaction to verify that journaling is disabled. + * + * Note that we will only get a transaction number of zero if + * journaling is disabled -- thus the following begin/end trans + * calls should fail if journaling is enabled. + */ + + begin_trans(cache_ptr, verbose, (uint64_t)0, "transaction 1.6"); + + insert_entry2(file_ptr, 0, 10, FALSE, H5C2__NO_FLAGS_SET); + protect_entry2(file_ptr, 0, 0); + unprotect_entry2(file_ptr, 0, 0, TRUE, H5C2__NO_FLAGS_SET); + + end_trans(file_ptr, cache_ptr, verbose, (uint64_t)0, "transaction 1.6"); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + if ( ( pass2 ) && ( cache_ptr->mdj_enabled ) ) { + + pass2 = FALSE; + failure_mssg2 = "journaling is enabled?!?!(1).\n"; + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + /* note that flush_journal() will throw an exception if journaling + * is not enabled, so we don't call it here. Instead, just call + * verify_journal_deleted() to verify that there is no journal file. + */ + + verify_journal_deleted(journal_filename); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /************************************************************/ + /* 6) Enable journaling on the open file. Do a transaction */ + /* or two to verify that journaling is working. */ + /************************************************************/ + + /* now enable journaling */ + if ( pass2 ) { + + mdj_config.version = H5C2__CURR_AUTO_SIZE_CTL_VER; + + result = H5Fget_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); + + if ( result < 0 ) { + + pass2 = FALSE; + failure_mssg2 = "H5Fget_mdc_config() failed.\n"; + } + + /* set journaling config fields to taste */ + mdj_config.enable_journaling = TRUE; + + strcpy(mdj_config.journal_file_path, journal_filename); + + mdj_config.journal_recovered = FALSE; + mdj_config.jbrb_buf_size = (8 * 1024); + mdj_config.jbrb_num_bufs = 2; + mdj_config.jbrb_use_aio = FALSE; + mdj_config.jbrb_human_readable = TRUE; + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + if ( pass2 ) { + + result = H5Fset_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); + + if ( result < 0 ) { + + pass2 = FALSE; + failure_mssg2 = "H5Fset_mdc_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + /* do a transaction or to to verify that journaling is working. */ + + begin_trans(cache_ptr, verbose, (uint64_t)1, "transaction 1.7"); + + insert_entry2(file_ptr, 0, 20, FALSE, H5C2__NO_FLAGS_SET); + protect_entry2(file_ptr, 0, 0); + unprotect_entry2(file_ptr, 0, 0, TRUE, H5C2__NO_FLAGS_SET); + + end_trans(file_ptr, cache_ptr, verbose, (uint64_t)1, "transaction 1.7"); + + flush_journal(cache_ptr); + + if ( update_architypes ) { + + copy_file(journal_filename, testfiles[18]); + } + + if ( file_exists(testfiles[18]) ) { + + verify_journal_contents(journal_filename, testfiles[18]); + + } else { + + testfile_missing = TRUE; + } + + flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /************************************************************/ + /* 7) Disable journaling on the open file. Verify that the */ + /* journal file has been deleted. */ + /************************************************************/ + + /* disable journaling */ + if ( pass2 ) { + + mdj_config.enable_journaling = FALSE; + + result = H5Fset_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); + + if ( result < 0 ) { + + pass2 = FALSE; + failure_mssg2 = "H5Fset_mdc_config() failed.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + verify_journal_deleted(journal_filename); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /*********************************/ + /* 8) Close and delete the file. */ + /*********************************/ + + if ( pass2 ) { + + if ( H5Fclose(file_id) < 0 ) { + + pass2 = FALSE; + failure_mssg2 = "H5Fclose(file_id) failed.\n"; + + } + } + + HDremove(journal_filename); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + if ( pass2 ) { + + PASSED(); + + if ( testfile_missing ) { + + puts(" WARNING: One or more missing test files."); + fflush(stdout); + } + } else { + + H5_FAILED(); + } + + if ( ! pass2 ) { + + failures2++; + HDfprintf(stdout, "%s: failure_mssg2 = \"%s\".\n", + fcn_name, failure_mssg2); + } + + return; + +} /* mdj_smoke_check_00() */ + + +/*------------------------------------------------------------------------- + * Function: mdj_smoke_check_01() + * + * Purpose: Run a cut down version of smoke_check_1 in cache2.c, with + * journaling enabled. Check the journal files generated, + * and verify that the journal output matches the architype + * test files. Skip the comparison and generate a warning + * if an architype file is missing. + * + * Return: void + * + * Programmer: John Mainzer + * 5/19/08 + * + * Changes: None. + * + *------------------------------------------------------------------------- + */ + +static void +mdj_smoke_check_01(void) +{ + const char * fcn_name = "mdj_smoke_check_01()"; + const char * testfiles[] = + { + "testfiles/cache2_journal_sc01_000.jnl", + "testfiles/cache2_journal_sc01_001.jnl", + "testfiles/cache2_journal_sc01_002.jnl", + "testfiles/cache2_journal_sc01_003.jnl", + "testfiles/cache2_journal_sc01_004.jnl", + NULL + }; + char filename[512]; + char journal_filename[H5AC2__MAX_JOURNAL_FILE_NAME_LEN + 1]; + hbool_t testfile_missing = FALSE; + hbool_t show_progress = FALSE; + hbool_t dirty_inserts = FALSE; + hbool_t verbose = FALSE; + hbool_t update_architypes = FALSE; + int dirty_unprotects = FALSE; + int dirty_destroys = FALSE; + hbool_t display_stats = FALSE; + int32_t lag = 10; + int cp = 0; + int32_t max_index = 128; + uint64_t trans_num = 0; + hid_t file_id = -1; + H5F_t * file_ptr = NULL; + H5C2_t * cache_ptr = NULL; + + TESTING("mdj smoke check 01 -- jrnl clean ins, prot, unprot, del, ren"); + + pass2 = TRUE; + + /********************************************************************/ + /* Create a file with cache configuration set to enable journaling. */ + /********************************************************************/ + + /* setup the file name */ + if ( pass2 ) { + + if ( h5_fixname(FILENAMES[1], H5P_DEFAULT, filename, sizeof(filename)) + == NULL ) { + + pass2 = FALSE; + failure_mssg2 = "h5_fixname() failed (1).\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + if ( verbose ) { + HDfprintf(stdout, "%s: filename = \"%s\".\n", fcn_name, filename); + } + + /* setup the journal file name */ + if ( pass2 ) { + + if ( h5_fixname(FILENAMES[3], H5P_DEFAULT, journal_filename, + sizeof(journal_filename)) == NULL ) { + + pass2 = FALSE; + failure_mssg2 = "h5_fixname() failed (2).\n"; + } + else if ( strlen(journal_filename) >= + H5AC2__MAX_JOURNAL_FILE_NAME_LEN ) { + + pass2 = FALSE; + failure_mssg2 = "journal file name too long.\n"; + } + } + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + if ( verbose ) { + HDfprintf(stdout, "%s: journal filename = \"%s\".\n", + fcn_name, journal_filename); + } + + /* clean out any existing journal file */ + HDremove(journal_filename); + + /* Unfortunately, we get different journal output depending on the + * file driver, as at present we are including the end of address + * space in journal entries, and the end of address space seems to + * be in part a function of the file driver. + * + * Thus, if we want to use the core file driver when available, we + * will either have to remove the end of address space from the + * journal entries, get the different file drivers to aggree on + * end of address space, or maintain different sets of architype + * files for the different file drivers. + */ + setup_cache_for_journaling(filename, journal_filename, &file_id, + &file_ptr, &cache_ptr, FALSE); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + + /******************************************/ + /* Run a small, fairly simple stress test */ + /******************************************/ + + trans_num = 0; + + jrnl_row_major_scan_forward2(/* file_ptr */ file_ptr, + /* max_index */ max_index, + /* lag */ lag, + /* verbose */ verbose, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ FALSE, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ TRUE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects, + /* trans_num */ trans_num); + + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + + flush_journal(cache_ptr); + + if ( update_architypes ) { + + copy_file(journal_filename, testfiles[0]); + } + + if ( file_exists(testfiles[0]) ) { + + verify_journal_contents(journal_filename, testfiles[0]); + + } else { + + testfile_missing = TRUE; + } + + flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ + verify_journal_empty(journal_filename); - /* b) Verify that the journal file has been deleted. */ - verify_journal_deleted(journal_filename); + trans_num = 0; if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - - /************************************************************/ - /* 5) Re-open the file with journaling disabled. Do a */ - /* transaction or two, and verify that the transactions */ - /* took place, and that there is no journal file. */ - /************************************************************/ - - /* re-open the file without journaling enabled */ - - open_existing_file_without_journaling(filename, &file_id, - &file_ptr, &cache_ptr); + jrnl_row_major_scan_backward2(/* file_ptr */ file_ptr, + /* max_index */ max_index, + /* lag */ lag, + /* verbose */ verbose, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ FALSE, + /* do_inserts */ FALSE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ TRUE, + /* do_destroys */ FALSE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects, + /* trans_num */ trans_num); if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + flush_journal(cache_ptr); - /* do a transaction to verify that journaling is disabled. - * - * Note that we will only get a transaction number of zero if - * journaling is disabled -- thus the following begin/end trans - * calls should fail if journaling is enabled. - */ + if ( update_architypes ) { - begin_trans(cache_ptr, verbose, (uint64_t)0, "transaction 1.6"); + copy_file(journal_filename, testfiles[1]); + } + + if ( file_exists(testfiles[1]) ) { - insert_entry2(file_ptr, 0, 10, FALSE, H5C2__NO_FLAGS_SET); - protect_entry2(file_ptr, 0, 0); - unprotect_entry2(file_ptr, 0, 0, TRUE, H5C2__NO_FLAGS_SET); + verify_journal_contents(journal_filename, testfiles[1]); - end_trans(file_ptr, cache_ptr, verbose, (uint64_t)0, "transaction 1.6"); + } else { - if ( show_progress ) - HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + testfile_missing = TRUE; + } - if ( ( pass2 ) && ( cache_ptr->mdj_enabled ) ) { + flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ - pass2 = FALSE; - failure_mssg2 = "journaling is enabled?!?!(1).\n"; - } + verify_journal_empty(journal_filename); + + trans_num = 0; if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - /* note that flush_journal() will throw an exception if journaling - * is not enabled, so we don't call it here. Instead, just call - * verify_journal_deleted() to verify that there is no journal file. - */ - - verify_journal_deleted(journal_filename); + jrnl_row_major_scan_forward2(/* file_ptr */ file_ptr, + /* max_index */ max_index, + /* lag */ lag, + /* verbose */ verbose, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ FALSE, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* do_renames */ TRUE, + /* rename_to_main_addr */ FALSE, + /* do_destroys */ TRUE, + /* do_mult_ro_protects */ TRUE, + /* dirty_destroys */ dirty_destroys, + /* dirty_unprotects */ dirty_unprotects, + /* trans_num */ trans_num); if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - - /************************************************************/ - /* 6) Enable journaling on the open file. Do a transaction */ - /* or two to verify that journaling is working. */ - /************************************************************/ + flush_journal(cache_ptr); - /* now enable journaling */ - if ( pass2 ) { + if ( update_architypes ) { - mdj_config.version = H5C2__CURR_AUTO_SIZE_CTL_VER; + copy_file(journal_filename, testfiles[2]); + } + + if ( file_exists(testfiles[2]) ) { - result = H5Fget_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); + verify_journal_contents(journal_filename, testfiles[2]); - if ( result < 0 ) { + } else { - pass2 = FALSE; - failure_mssg2 = "H5Fget_mdc_config() failed.\n"; - } + testfile_missing = TRUE; + } - /* set journaling config fields to taste */ - mdj_config.enable_journaling = TRUE; + flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ - strcpy(mdj_config.journal_file_path, journal_filename); + trans_num = 0; - mdj_config.journal_recovered = FALSE; - mdj_config.jbrb_buf_size = (8 * 1024); - mdj_config.jbrb_num_bufs = 2; - mdj_config.jbrb_use_aio = FALSE; - mdj_config.jbrb_human_readable = TRUE; - } + verify_journal_empty(journal_filename); if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - if ( pass2 ) { - - result = H5Fset_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); - - if ( result < 0 ) { - - pass2 = FALSE; - failure_mssg2 = "H5Fset_mdc_config() failed.\n"; - } - } + jrnl_col_major_scan_forward2(/* file_ptr */ file_ptr, + /* max_index */ max_index, + /* lag */ lag, + /* verbose */ verbose, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects, + /* trans_num */ trans_num); if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - /* do a transaction or to to verify that journaling is working. */ - - begin_trans(cache_ptr, verbose, (uint64_t)1, "transaction 1.7"); - - insert_entry2(file_ptr, 0, 20, FALSE, H5C2__NO_FLAGS_SET); - protect_entry2(file_ptr, 0, 0); - unprotect_entry2(file_ptr, 0, 0, TRUE, H5C2__NO_FLAGS_SET); - - end_trans(file_ptr, cache_ptr, verbose, (uint64_t)1, "transaction 1.7"); - flush_journal(cache_ptr); if ( update_architypes ) { - copy_file(journal_filename, testfiles[18]); + copy_file(journal_filename, testfiles[3]); } - if ( file_exists(testfiles[18]) ) { + if ( file_exists(testfiles[3]) ) { - verify_journal_contents(journal_filename, testfiles[18]); + verify_journal_contents(journal_filename, testfiles[3]); } else { @@ -4125,53 +4698,58 @@ mdj_smoke_check_00(void) flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ + verify_journal_empty(journal_filename); + + trans_num = 0; + if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - - /************************************************************/ - /* 7) Disable journaling on the open file. Verify that the */ - /* journal file has been deleted. */ - /************************************************************/ - - /* disable journaling */ - if ( pass2 ) { + jrnl_col_major_scan_backward2(/* file_ptr */ file_ptr, + /* max_index */ max_index, + /* lag */ lag, + /* verbose */ verbose, + /* reset_stats */ TRUE, + /* display_stats */ display_stats, + /* display_detailed_stats */ TRUE, + /* do_inserts */ TRUE, + /* dirty_inserts */ dirty_inserts, + /* dirty_unprotects */ dirty_unprotects, + /* trans_num */ trans_num); - mdj_config.enable_journaling = FALSE; + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - result = H5Fset_mdc_config(file_id, (H5AC_cache_config_t *)&mdj_config); + flush_journal(cache_ptr); - if ( result < 0 ) { + if ( update_architypes ) { - pass2 = FALSE; - failure_mssg2 = "H5Fset_mdc_config() failed.\n"; - } + copy_file(journal_filename, testfiles[4]); } + + if ( file_exists(testfiles[4]) ) { - if ( show_progress ) - HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); + verify_journal_contents(journal_filename, testfiles[4]); - verify_journal_deleted(journal_filename); + } else { + + testfile_missing = TRUE; + } if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - - /*********************************/ - /* 8) Close and delete the file. */ - /*********************************/ - - if ( pass2 ) { - - if ( H5Fclose(file_id) < 0 ) { + /****************************************************/ + /* Close and discard the file and the journal file. */ + /****************************************************/ - pass2 = FALSE; - failure_mssg2 = "H5Fclose(file_id) failed.\n"; + takedown_cache_after_journaling(file_id, filename, journal_filename, FALSE); - } - } + if ( show_progress ) + HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); - HDremove(journal_filename); + verify_clean2(); + verify_unprotected2(); if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); @@ -4199,17 +4777,17 @@ mdj_smoke_check_00(void) return; -} /* mdj_smoke_check_00() */ +} /* mdj_smoke_check_01() */ /*------------------------------------------------------------------------- - * Function: mdj_smoke_check_01() + * Function: mdj_smoke_check_02() * - * Purpose: Run a cut down version of smoke_check_1 in cache2.c, with + * Purpose: Run a cut down version of smoke_check_2 in cache2.c, with * journaling enabled. Check the journal files generated, * and verify that the journal output matches the architype - * test files. Skip the test if these architypes are not - * present. + * test files. Skip the comparison and generate a warning + * if an architype file is missing. * * Return: void * @@ -4222,24 +4800,27 @@ mdj_smoke_check_00(void) */ static void -mdj_smoke_check_01(void) +mdj_smoke_check_02(void) { - const char * fcn_name = "mdj_smoke_check_01()"; + const char * fcn_name = "mdj_smoke_check_02()"; const char * testfiles[] = { - "testfiles/cache2_journal_sc01_000.jnl", - "testfiles/cache2_journal_sc01_001.jnl", + "testfiles/cache2_journal_sc02_000.jnl", + "testfiles/cache2_journal_sc02_001.jnl", + "testfiles/cache2_journal_sc02_002.jnl", + "testfiles/cache2_journal_sc02_003.jnl", + "testfiles/cache2_journal_sc02_004.jnl", NULL }; char filename[512]; char journal_filename[H5AC2__MAX_JOURNAL_FILE_NAME_LEN + 1]; hbool_t testfile_missing = FALSE; hbool_t show_progress = FALSE; - hbool_t dirty_inserts = FALSE; + hbool_t dirty_inserts = TRUE; hbool_t verbose = FALSE; hbool_t update_architypes = FALSE; - int dirty_unprotects = FALSE; - int dirty_destroys = FALSE; + int dirty_unprotects = TRUE; + int dirty_destroys = TRUE; hbool_t display_stats = FALSE; int32_t lag = 10; int cp = 0; @@ -4249,7 +4830,7 @@ mdj_smoke_check_01(void) H5F_t * file_ptr = NULL; H5C2_t * cache_ptr = NULL; - TESTING("mdj smoke check 01 -- jrnl ins, prot, unprot"); + TESTING("mdj smoke check 02 -- jrnl dirty ins, prot, unprot, del, ren"); pass2 = TRUE; @@ -4326,7 +4907,7 @@ mdj_smoke_check_01(void) /******************************************/ trans_num = 0; -#if 0 /* JRM */ /* this section is in-op at present */ + jrnl_row_major_scan_forward2(/* file_ptr */ file_ptr, /* max_index */ max_index, /* lag */ lag, @@ -4428,7 +5009,7 @@ mdj_smoke_check_01(void) /* dirty_inserts */ dirty_inserts, /* do_renames */ TRUE, /* rename_to_main_addr */ FALSE, - /* do_destroys */ TRUE, + /* do_destroys */ FALSE, /* do_mult_ro_protects */ TRUE, /* dirty_destroys */ dirty_destroys, /* dirty_unprotects */ dirty_unprotects, @@ -4455,10 +5036,10 @@ mdj_smoke_check_01(void) flush_cache2(file_ptr, FALSE, FALSE, FALSE); /* resets transaction number */ - verify_journal_empty(journal_filename); -#endif /* JRM */ trans_num = 0; + verify_journal_empty(journal_filename); + if ( show_progress ) HDfprintf(stdout, "%s:%d cp = %d.\n", fcn_name, pass2, cp++); @@ -4481,12 +5062,12 @@ mdj_smoke_check_01(void) if ( update_architypes ) { - copy_file(journal_filename, testfiles[0]); + copy_file(journal_filename, testfiles[3]); } - if ( file_exists(testfiles[0]) ) { + if ( file_exists(testfiles[3]) ) { - verify_journal_contents(journal_filename, testfiles[0]); + verify_journal_contents(journal_filename, testfiles[3]); } else { @@ -4521,12 +5102,12 @@ mdj_smoke_check_01(void) if ( update_architypes ) { - copy_file(journal_filename, testfiles[1]); + copy_file(journal_filename, testfiles[4]); } - if ( file_exists(testfiles[1]) ) { + if ( file_exists(testfiles[4]) ) { - verify_journal_contents(journal_filename, testfiles[1]); + verify_journal_contents(journal_filename, testfiles[4]); } else { @@ -4574,7 +5155,7 @@ mdj_smoke_check_01(void) return; -} /* mdj_smoke_check_01() */ +} /* mdj_smoke_check_02() */ /*** metatada journaling config block I/O test code ***/ @@ -10374,6 +10955,9 @@ main(void) mdj_smoke_check_01(); #endif #if 1 + mdj_smoke_check_02(); +#endif +#if 1 check_buffer_writes(); check_legal_calls(); check_message_format(); diff --git a/test/testfiles/cache2_journal_sc01_000.jnl.gz b/test/testfiles/cache2_journal_sc01_000.jnl.gz index ce4c67e..5d37f04 100755 Binary files a/test/testfiles/cache2_journal_sc01_000.jnl.gz and b/test/testfiles/cache2_journal_sc01_000.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc01_001.jnl.gz b/test/testfiles/cache2_journal_sc01_001.jnl.gz index 8fc2005..669a307 100755 Binary files a/test/testfiles/cache2_journal_sc01_001.jnl.gz and b/test/testfiles/cache2_journal_sc01_001.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc01_002.jnl.gz b/test/testfiles/cache2_journal_sc01_002.jnl.gz new file mode 100755 index 0000000..a684d6d Binary files /dev/null and b/test/testfiles/cache2_journal_sc01_002.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc01_003.jnl.gz b/test/testfiles/cache2_journal_sc01_003.jnl.gz new file mode 100755 index 0000000..c9265ff Binary files /dev/null and b/test/testfiles/cache2_journal_sc01_003.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc01_004.jnl.gz b/test/testfiles/cache2_journal_sc01_004.jnl.gz new file mode 100755 index 0000000..aacc153 Binary files /dev/null and b/test/testfiles/cache2_journal_sc01_004.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc02_000.jnl.gz b/test/testfiles/cache2_journal_sc02_000.jnl.gz new file mode 100755 index 0000000..d5675ed Binary files /dev/null and b/test/testfiles/cache2_journal_sc02_000.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc02_001.jnl.gz b/test/testfiles/cache2_journal_sc02_001.jnl.gz new file mode 100755 index 0000000..6a8fbf7 Binary files /dev/null and b/test/testfiles/cache2_journal_sc02_001.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc02_002.jnl.gz b/test/testfiles/cache2_journal_sc02_002.jnl.gz new file mode 100755 index 0000000..121017e Binary files /dev/null and b/test/testfiles/cache2_journal_sc02_002.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc02_003.jnl.gz b/test/testfiles/cache2_journal_sc02_003.jnl.gz new file mode 100755 index 0000000..b5dbf0a Binary files /dev/null and b/test/testfiles/cache2_journal_sc02_003.jnl.gz differ diff --git a/test/testfiles/cache2_journal_sc02_004.jnl.gz b/test/testfiles/cache2_journal_sc02_004.jnl.gz new file mode 100755 index 0000000..6b16e37 Binary files /dev/null and b/test/testfiles/cache2_journal_sc02_004.jnl.gz differ -- cgit v0.12